Skip to content

Commit 65d62dc

Browse files
authored
Merge pull request #909 from nobu/macro_args
Fix macro arguments
2 parents 28c57df + 8fb7279 commit 65d62dc

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

ext/json/ext/generator/generator.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ typedef struct _search_state {
128128
#endif /* HAVE_SIMD */
129129
} search_state;
130130

131-
static ALWAYS_INLINE() void search_flush(search_state *search)
131+
ALWAYS_INLINE(static) void search_flush(search_state *search)
132132
{
133133
// Do not remove this conditional without profiling, specifically escape-heavy text.
134134
// escape_UTF8_char_basic will advance search->ptr and search->cursor (effectively a search_flush).
@@ -171,7 +171,7 @@ static inline unsigned char search_escape_basic(search_state *search)
171171
return 0;
172172
}
173173

174-
static ALWAYS_INLINE() void escape_UTF8_char_basic(search_state *search)
174+
ALWAYS_INLINE(static) void escape_UTF8_char_basic(search_state *search)
175175
{
176176
const unsigned char ch = (unsigned char)*search->ptr;
177177
switch (ch) {
@@ -258,7 +258,7 @@ static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
258258

259259
#ifdef HAVE_SIMD
260260

261-
static ALWAYS_INLINE() char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
261+
ALWAYS_INLINE(static) char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
262262
{
263263
// Flush the buffer so everything up until the last 'len' characters are unflushed.
264264
search_flush(search);
@@ -281,7 +281,7 @@ static ALWAYS_INLINE() char *copy_remaining_bytes(search_state *search, unsigned
281281

282282
#ifdef HAVE_SIMD_NEON
283283

284-
static ALWAYS_INLINE() unsigned char neon_next_match(search_state *search)
284+
ALWAYS_INLINE(static) unsigned char neon_next_match(search_state *search)
285285
{
286286
uint64_t mask = search->matches_mask;
287287
uint32_t index = trailing_zeros64(mask) >> 2;
@@ -395,7 +395,7 @@ static inline unsigned char search_escape_basic_neon(search_state *search)
395395

396396
#ifdef HAVE_SIMD_SSE2
397397

398-
static ALWAYS_INLINE() unsigned char sse2_next_match(search_state *search)
398+
ALWAYS_INLINE(static) unsigned char sse2_next_match(search_state *search)
399399
{
400400
int mask = search->matches_mask;
401401
int index = trailing_zeros(mask);
@@ -419,7 +419,7 @@ static ALWAYS_INLINE() unsigned char sse2_next_match(search_state *search)
419419
#define TARGET_SSE2
420420
#endif
421421

422-
static TARGET_SSE2 ALWAYS_INLINE() unsigned char search_escape_basic_sse2(search_state *search)
422+
ALWAYS_INLINE(static) TARGET_SSE2 unsigned char search_escape_basic_sse2(search_state *search)
423423
{
424424
if (RB_UNLIKELY(search->has_matches)) {
425425
// There are more matches if search->matches_mask > 0.
@@ -1123,8 +1123,7 @@ struct hash_foreach_arg {
11231123
bool mixed_keys_encountered;
11241124
};
11251125

1126-
NOINLINE()
1127-
static void
1126+
NOINLINE(static) void
11281127
json_inspect_hash_with_mixed_keys(struct hash_foreach_arg *arg)
11291128
{
11301129
if (arg->mixed_keys_encountered) {

ext/json/ext/parser/parser.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void rvalue_cache_insert_at(rvalue_cache *cache, int index, VALUE rstring
8888
#if JSON_CPU_LITTLE_ENDIAN_64BITS
8989
#if __has_builtin(__builtin_bswap64)
9090
#undef rstring_cache_memcmp
91-
static ALWAYS_INLINE() int rstring_cache_memcmp(const char *str, const char *rptr, const long length)
91+
ALWAYS_INLINE(static) int rstring_cache_memcmp(const char *str, const char *rptr, const long length)
9292
{
9393
// The libc memcmp has numerous complex optimizations, but in this particular case,
9494
// we know the string is small (JSON_RVALUE_CACHE_MAX_ENTRY_LENGTH), so being able to
@@ -117,7 +117,7 @@ static ALWAYS_INLINE() int rstring_cache_memcmp(const char *str, const char *rpt
117117
#endif
118118
#endif
119119

120-
static ALWAYS_INLINE() int rstring_cache_cmp(const char *str, const long length, VALUE rstring)
120+
ALWAYS_INLINE(static) int rstring_cache_cmp(const char *str, const long length, VALUE rstring)
121121
{
122122
const char *rstring_ptr;
123123
long rstring_length;
@@ -131,7 +131,7 @@ static ALWAYS_INLINE() int rstring_cache_cmp(const char *str, const long length,
131131
}
132132
}
133133

134-
static ALWAYS_INLINE() VALUE rstring_cache_fetch(rvalue_cache *cache, const char *str, const long length)
134+
ALWAYS_INLINE(static) VALUE rstring_cache_fetch(rvalue_cache *cache, const char *str, const long length)
135135
{
136136
int low = 0;
137137
int high = cache->length - 1;
@@ -540,7 +540,7 @@ json_eat_comments(JSON_ParserState *state)
540540
}
541541
}
542542

543-
static ALWAYS_INLINE() void
543+
ALWAYS_INLINE(static) void
544544
json_eat_whitespace(JSON_ParserState *state)
545545
{
546546
while (true) {
@@ -661,7 +661,7 @@ static inline const char *json_next_backslash(const char *pe, const char *string
661661
return NULL;
662662
}
663663

664-
static NOINLINE() VALUE json_string_unescape(JSON_ParserState *state, JSON_ParserConfig *config, const char *string, const char *stringEnd, bool is_name, JSON_UnescapePositions *positions)
664+
NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_ParserConfig *config, const char *string, const char *stringEnd, bool is_name, JSON_UnescapePositions *positions)
665665
{
666666
bool intern = is_name || config->freeze;
667667
bool symbolize = is_name && config->symbolize_names;
@@ -946,7 +946,7 @@ static const bool string_scan_table[256] = {
946946
static SIMD_Implementation simd_impl = SIMD_NONE;
947947
#endif /* HAVE_SIMD */
948948

949-
static ALWAYS_INLINE() bool string_scan(JSON_ParserState *state)
949+
ALWAYS_INLINE(static) bool string_scan(JSON_ParserState *state)
950950
{
951951
#ifdef HAVE_SIMD
952952
#if defined(HAVE_SIMD_NEON)
@@ -1015,7 +1015,7 @@ static VALUE json_parse_escaped_string(JSON_ParserState *state, JSON_ParserConfi
10151015
return Qfalse;
10161016
}
10171017

1018-
static ALWAYS_INLINE() VALUE json_parse_string(JSON_ParserState *state, JSON_ParserConfig *config, bool is_name)
1018+
ALWAYS_INLINE(static) VALUE json_parse_string(JSON_ParserState *state, JSON_ParserConfig *config, bool is_name)
10191019
{
10201020
state->cursor++;
10211021
const char *start = state->cursor;

ext/json/ext/simd/simd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ static inline SIMD_Implementation find_simd_implementation(void)
7373
#define HAVE_SIMD_NEON 1
7474

7575
// See: https://community.arm.com/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/porting-x86-vector-bitmask-optimizations-to-arm-neon
76-
static ALWAYS_INLINE() uint64_t neon_match_mask(uint8x16_t matches)
76+
ALWAYS_INLINE(static) uint64_t neon_match_mask(uint8x16_t matches)
7777
{
7878
const uint8x8_t res = vshrn_n_u16(vreinterpretq_u16_u8(matches), 4);
7979
const uint64_t mask = vget_lane_u64(vreinterpret_u64_u8(res), 0);
8080
return mask & 0x8888888888888888ull;
8181
}
8282

83-
static ALWAYS_INLINE() uint64_t compute_chunk_mask_neon(const char *ptr)
83+
ALWAYS_INLINE(static) uint64_t compute_chunk_mask_neon(const char *ptr)
8484
{
8585
uint8x16_t chunk = vld1q_u8((const unsigned char *)ptr);
8686

@@ -93,7 +93,7 @@ static ALWAYS_INLINE() uint64_t compute_chunk_mask_neon(const char *ptr)
9393
return neon_match_mask(needs_escape);
9494
}
9595

96-
static ALWAYS_INLINE() int string_scan_simd_neon(const char **ptr, const char *end, uint64_t *mask)
96+
ALWAYS_INLINE(static) int string_scan_simd_neon(const char **ptr, const char *end, uint64_t *mask)
9797
{
9898
while (*ptr + sizeof(uint8x16_t) <= end) {
9999
uint64_t chunk_mask = compute_chunk_mask_neon(*ptr);
@@ -140,7 +140,7 @@ static inline uint8x16x4_t load_uint8x16_4(const unsigned char *table)
140140
#define _mm_cmpgt_epu8(a, b) _mm_xor_si128(_mm_cmple_epu8(a, b), _mm_set1_epi8(-1))
141141
#define _mm_cmplt_epu8(a, b) _mm_cmpgt_epu8(b, a)
142142

143-
static TARGET_SSE2 ALWAYS_INLINE() int compute_chunk_mask_sse2(const char *ptr)
143+
ALWAYS_INLINE(static) TARGET_SSE2 int compute_chunk_mask_sse2(const char *ptr)
144144
{
145145
__m128i chunk = _mm_loadu_si128((__m128i const*)ptr);
146146
// Trick: c < 32 || c == 34 can be factored as c ^ 2 < 33
@@ -151,7 +151,7 @@ static TARGET_SSE2 ALWAYS_INLINE() int compute_chunk_mask_sse2(const char *ptr)
151151
return _mm_movemask_epi8(needs_escape);
152152
}
153153

154-
static TARGET_SSE2 ALWAYS_INLINE() int string_scan_simd_sse2(const char **ptr, const char *end, int *mask)
154+
ALWAYS_INLINE(static) TARGET_SSE2 int string_scan_simd_sse2(const char **ptr, const char *end, int *mask)
155155
{
156156
while (*ptr + sizeof(__m128i) <= end) {
157157
int chunk_mask = compute_chunk_mask_sse2(*ptr);

0 commit comments

Comments
 (0)