summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-02-06 09:33:07 +0100
committergit <svn-admin@ruby-lang.org>2026-02-06 08:48:29 +0000
commit17caec3cab53f16ab4e338858560519082e5dd48 (patch)
treea383842a090cdbe6208684a6aed0f92e84720914 /ext
parentf841f9fc9459d033fa7fb18caaa6e1eb3ac7195d (diff)
[ruby/json] Cleanup function delecarations
https://github.com/ruby/json/commit/7ddf3499d0
Diffstat (limited to 'ext')
-rw-r--r--ext/json/json.h4
-rw-r--r--ext/json/parser/parser.c24
2 files changed, 11 insertions, 17 deletions
diff --git a/ext/json/json.h b/ext/json/json.h
index 9379d7ae7f..087a2eae66 100644
--- a/ext/json/json.h
+++ b/ext/json/json.h
@@ -55,8 +55,12 @@ typedef unsigned char _Bool;
#endif
#ifndef NORETURN
+#if defined(__has_attribute) && __has_attribute(noreturn)
+#define NORETURN(x) __attribute__((noreturn)) x
+#else
#define NORETURN(x) x
#endif
+#endif
#ifndef NOINLINE
#if defined(__has_attribute) && __has_attribute(noinline)
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index f1ea1b6abb..93e3b021f1 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -400,10 +400,7 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
#define PARSE_ERROR_FRAGMENT_LEN 32
-#ifdef RBIMPL_ATTR_NORETURN
-RBIMPL_ATTR_NORETURN()
-#endif
-static void raise_parse_error(const char *format, JSON_ParserState *state)
+NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
{
unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
long line, column;
@@ -449,10 +446,7 @@ static void raise_parse_error(const char *format, JSON_ParserState *state)
rb_exc_raise(exc);
}
-#ifdef RBIMPL_ATTR_NORETURN
-RBIMPL_ATTR_NORETURN()
-#endif
-static void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
+NORETURN(static) void raise_parse_error_at(const char *format, JSON_ParserState *state, const char *at)
{
state->cursor = at;
raise_parse_error(format, state);
@@ -777,7 +771,7 @@ NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_Parser
#define MAX_FAST_INTEGER_SIZE 18
-static VALUE json_decode_large_integer(const char *start, long len)
+NOINLINE(static) VALUE json_decode_large_integer(const char *start, long len)
{
VALUE buffer_v;
char *buffer = RB_ALLOCV_N(char, buffer_v, len + 1);
@@ -788,8 +782,7 @@ static VALUE json_decode_large_integer(const char *start, long len)
return number;
}
-static inline VALUE
-json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const char *start, const char *end)
+static inline VALUE json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const char *start, const char *end)
{
if (RB_LIKELY(mantissa_digits < MAX_FAST_INTEGER_SIZE)) {
if (negative) {
@@ -801,7 +794,7 @@ json_decode_integer(uint64_t mantissa, int mantissa_digits, bool negative, const
return json_decode_large_integer(start, end - start);
}
-static VALUE json_decode_large_float(const char *start, long len)
+NOINLINE(static) VALUE json_decode_large_float(const char *start, long len)
{
if (RB_LIKELY(len < 64)) {
char buffer[64];
@@ -868,7 +861,7 @@ static VALUE json_find_duplicated_key(size_t count, const VALUE *pairs)
return Qfalse;
}
-static void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_key)
+NOINLINE(static) void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_key)
{
VALUE message = rb_sprintf(
"detected duplicate key %"PRIsVALUE" in JSON object. This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`",
@@ -879,10 +872,7 @@ static void emit_duplicate_key_warning(JSON_ParserState *state, VALUE duplicate_
RB_GC_GUARD(message);
}
-#ifdef RBIMPL_ATTR_NORETURN
-RBIMPL_ATTR_NORETURN()
-#endif
-static void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_key)
+NORETURN(static) void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_key)
{
VALUE message = rb_sprintf(
"duplicate key %"PRIsVALUE,