1- #include "ruby .h"
1+ #include "../json .h"
22#include "../fbuffer/fbuffer.h"
33#include "../vendor/fpconv.c"
44
@@ -36,10 +36,6 @@ typedef struct JSON_Generator_StateStruct {
3636 bool strict ;
3737} JSON_Generator_State ;
3838
39- #ifndef RB_UNLIKELY
40- #define RB_UNLIKELY (cond ) (cond)
41- #endif
42-
4339static VALUE mJSON , cState , cFragment , eGeneratorError , eNestingError , Encoding_UTF_8 ;
4440
4541static ID i_to_s , i_to_json , i_new , i_pack , i_unpack , i_create_id , i_extend , i_encode ;
@@ -85,24 +81,18 @@ static void generate_json_fragment(FBuffer *buffer, struct generate_json_data *d
8581
8682static int usascii_encindex , utf8_encindex , binary_encindex ;
8783
88- #ifdef RBIMPL_ATTR_NORETURN
89- RBIMPL_ATTR_NORETURN ()
90- #endif
91- static void raise_generator_error_str (VALUE invalid_object , VALUE str )
84+ NORETURN (static void ) raise_generator_error_str (VALUE invalid_object , VALUE str )
9285{
9386 rb_enc_associate_index (str , utf8_encindex );
9487 VALUE exc = rb_exc_new_str (eGeneratorError , str );
9588 rb_ivar_set (exc , rb_intern ("@invalid_object" ), invalid_object );
9689 rb_exc_raise (exc );
9790}
9891
99- #ifdef RBIMPL_ATTR_NORETURN
100- RBIMPL_ATTR_NORETURN ()
101- #endif
10292#ifdef RBIMPL_ATTR_FORMAT
10393RBIMPL_ATTR_FORMAT (RBIMPL_PRINTF_FORMAT , 2 , 3 )
10494#endif
105- static void raise_generator_error (VALUE invalid_object , const char * fmt , ...)
95+ NORETURN ( static void ) raise_generator_error (VALUE invalid_object , const char * fmt , ...)
10696{
10797 va_list args ;
10898 va_start (args , fmt );
@@ -137,13 +127,7 @@ typedef struct _search_state {
137127#endif /* HAVE_SIMD */
138128} search_state ;
139129
140- #if (defined(__GNUC__ ) || defined(__clang__ ))
141- #define FORCE_INLINE __attribute__((always_inline))
142- #else
143- #define FORCE_INLINE
144- #endif
145-
146- static inline FORCE_INLINE void search_flush (search_state * search )
130+ static ALWAYS_INLINE () void search_flush (search_state * search )
147131{
148132 // Do not remove this conditional without profiling, specifically escape-heavy text.
149133 // escape_UTF8_char_basic will advance search->ptr and search->cursor (effectively a search_flush).
@@ -186,7 +170,7 @@ static inline unsigned char search_escape_basic(search_state *search)
186170 return 0 ;
187171}
188172
189- static inline FORCE_INLINE void escape_UTF8_char_basic (search_state * search )
173+ static ALWAYS_INLINE () void escape_UTF8_char_basic (search_state * search )
190174{
191175 const unsigned char ch = (unsigned char )* search -> ptr ;
192176 switch (ch ) {
@@ -273,7 +257,7 @@ static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
273257
274258#ifdef HAVE_SIMD
275259
276- static inline FORCE_INLINE char * copy_remaining_bytes (search_state * search , unsigned long vec_len , unsigned long len )
260+ static ALWAYS_INLINE () char * copy_remaining_bytes (search_state * search , unsigned long vec_len , unsigned long len )
277261{
278262 // Flush the buffer so everything up until the last 'len' characters are unflushed.
279263 search_flush (search );
@@ -296,7 +280,7 @@ static inline FORCE_INLINE char *copy_remaining_bytes(search_state *search, unsi
296280
297281#ifdef HAVE_SIMD_NEON
298282
299- static inline FORCE_INLINE unsigned char neon_next_match (search_state * search )
283+ static ALWAYS_INLINE () unsigned char neon_next_match (search_state * search )
300284{
301285 uint64_t mask = search -> matches_mask ;
302286 uint32_t index = trailing_zeros64 (mask ) >> 2 ;
@@ -410,7 +394,7 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
410394
411395#ifdef HAVE_SIMD_SSE2
412396
413- static inline FORCE_INLINE unsigned char sse2_next_match (search_state * search )
397+ static ALWAYS_INLINE () unsigned char sse2_next_match (search_state * search )
414398{
415399 int mask = search -> matches_mask ;
416400 int index = trailing_zeros (mask );
@@ -434,7 +418,7 @@ static inline FORCE_INLINE unsigned char sse2_next_match(search_state *search)
434418#define TARGET_SSE2
435419#endif
436420
437- static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2 (search_state * search )
421+ static inline TARGET_SSE2 ALWAYS_INLINE () unsigned char search_escape_basic_sse2 (search_state * search )
438422{
439423 if (RB_UNLIKELY (search -> has_matches )) {
440424 // There are more matches if search->matches_mask > 0.
0 commit comments