Skip to content

Commit cb82efc

Browse files
authored
Update extensions for rb_len_t (#1133)
* Update extensions for `rb_len_t` * Split the conditions for each definition of the `rb_len_t` macro Since the update to the Windows binaries used by `setup-ruby` has stalled at an incomplete stage, temporarily split the conditions.
1 parent 3c05e0a commit cb82efc

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎ext/json/ext/fbuffer/fbuffer.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct FBufferStruct {
3333
static void fbuffer_free(FBuffer *fb);
3434
static void fbuffer_clear(FBuffer *fb);
3535
static void fbuffer_append(FBuffer *fb, const char *newstr, size_t len);
36-
static void fbuffer_append_long(FBuffer *fb, long number);
36+
static void fbuffer_append_len(FBuffer *fb, rb_len_t number);
3737
static inline void fbuffer_append_char(FBuffer *fb, char newchr);
3838
static VALUE fbuffer_finalize(FBuffer *fb);
3939

@@ -218,7 +218,7 @@ static inline void fbuffer_advance_to(FBuffer *fb, char *end)
218218
/*
219219
* Appends the decimal string representation of \a number into the buffer.
220220
*/
221-
static void fbuffer_append_long(FBuffer *fb, long number)
221+
static void fbuffer_append_len(FBuffer *fb, rb_len_t number)
222222
{
223223
/*
224224
* The jeaiii_ultoa() function produces digits left-to-right,
@@ -231,9 +231,9 @@ static void fbuffer_append_long(FBuffer *fb, long number)
231231
* generated is therefore 20 (including a potential sign character).
232232
*/
233233

234-
static const int MAX_CHARS_FOR_LONG = 20;
234+
static const int MAX_CHARS_FOR_LEN = 20;
235235

236-
fbuffer_inc_capa(fb, MAX_CHARS_FOR_LONG);
236+
fbuffer_inc_capa(fb, MAX_CHARS_FOR_LEN);
237237

238238
if (number < 0) {
239239
fbuffer_append_reserved_char(fb, '-');

‎ext/json/ext/generator/generator.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ struct generate_json_data {
5959
long depth;
6060
};
6161

62+
#if defined(HAVE_SIMD) && defined(HAVE_SIMD_SSE2)
6263
static SIMD_Implementation simd_impl;
64+
# define init_simd_impl() (simd_impl = find_simd_implementation())
65+
#else
66+
# define init_simd_impl() (void)0
67+
#endif
6368

6469
static VALUE cState_from_state_s(VALUE self, VALUE opts);
6570
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
11611166
generate_json_rfc8785_number(buffer, obj);
11621167
return;
11631168
}
1164-
fbuffer_append_long(buffer, FIX2LONG(obj));
1169+
fbuffer_append_len(buffer, FIX2LEN(obj));
11651170
}
11661171

11671172
static void generate_json_bignum(FBuffer *buffer, struct generate_json_data *data, VALUE obj)
@@ -2171,5 +2176,5 @@ void Init_generator(void)
21712176

21722177
rb_require("json/ext/generator/state");
21732178

2174-
simd_impl = find_simd_implementation();
2179+
init_simd_impl();
21752180
}

‎ext/json/ext/json.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
#ifndef HAVE_RB_LEN_T
99
typedef long rb_len_t;
10+
#endif
11+
#ifndef FIX2LEN
12+
# define FIX2LEN FIX2LONG
13+
#endif
14+
#ifndef LEN2NUM
1015
# define LEN2NUM LONG2NUM
16+
#endif
17+
#ifndef PRIdLEN
1118
# define PRIdLEN "ld"
1219
#endif
1320

0 commit comments

Comments
 (0)