diff --git a/ext/json/ext/fbuffer/fbuffer.h b/ext/json/ext/fbuffer/fbuffer.h index 3f95f1f76..2616c03bd 100644 --- a/ext/json/ext/fbuffer/fbuffer.h +++ b/ext/json/ext/fbuffer/fbuffer.h @@ -33,7 +33,7 @@ typedef struct FBufferStruct { static void fbuffer_free(FBuffer *fb); static void fbuffer_clear(FBuffer *fb); static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len); -static void fbuffer_append_long(FBuffer *fb, long number); +static void fbuffer_append_len(FBuffer *fb, rb_len_t number); static inline void fbuffer_append_char(FBuffer *fb, char newchr); static VALUE fbuffer_finalize(FBuffer *fb); @@ -218,7 +218,7 @@ static inline void fbuffer_advance_to(FBuffer *fb, char *end) /* * Appends the decimal string representation of \a number into the buffer. */ -static void fbuffer_append_long(FBuffer *fb, long number) +static void fbuffer_append_len(FBuffer *fb, rb_len_t number) { /* * The jeaiii_ultoa() function produces digits left-to-right, @@ -231,9 +231,9 @@ static void fbuffer_append_long(FBuffer *fb, long number) * generated is therefore 20 (including a potential sign character). */ - static const int MAX_CHARS_FOR_LONG = 20; + static const int MAX_CHARS_FOR_LEN = 20; - fbuffer_inc_capa(fb, MAX_CHARS_FOR_LONG); + fbuffer_inc_capa(fb, MAX_CHARS_FOR_LEN); if (number < 0) { fbuffer_append_reserved_char(fb, '-'); diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index 87da10027..bc2e73726 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -59,7 +59,12 @@ struct generate_json_data { long depth; }; +#if defined(HAVE_SIMD) && defined(HAVE_SIMD_SSE2) static SIMD_Implementation simd_impl; +# define init_simd_impl() (simd_impl = find_simd_implementation()) +#else +# define init_simd_impl() (void)0 +#endif static VALUE cState_from_state_s(VALUE self, VALUE opts); static VALUE cState_partial_generate(VALUE self, VALUE obj, generator_func, VALUE io); @@ -1161,7 +1166,7 @@ static void generate_json_fixnum(FBuffer *buffer, struct generate_json_data *dat generate_json_rfc8785_number(buffer, obj); return; } - fbuffer_append_long(buffer, FIX2LONG(obj)); + fbuffer_append_len(buffer, FIX2LEN(obj)); } static void generate_json_bignum(FBuffer *buffer, struct generate_json_data *data, VALUE obj) @@ -2171,5 +2176,5 @@ void Init_generator(void) rb_require("json/ext/generator/state"); - simd_impl = find_simd_implementation(); + init_simd_impl(); } diff --git a/ext/json/ext/json.h b/ext/json/ext/json.h index a402182d0..ba2ac2b75 100644 --- a/ext/json/ext/json.h +++ b/ext/json/ext/json.h @@ -7,7 +7,14 @@ #ifndef HAVE_RB_LEN_T typedef long rb_len_t; +#endif +#ifndef FIX2LEN +# define FIX2LEN FIX2LONG +#endif +#ifndef LEN2NUM # define LEN2NUM LONG2NUM +#endif +#ifndef PRIdLEN # define PRIdLEN "ld" #endif