Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ typedef struct _search_state {
const char *cursor;
FBuffer *buffer;

#ifdef JSON_ENABLE_SIMD
#ifdef HAVE_SIMD
const char *chunk_base;
const char *chunk_end;
bool has_matches;
Expand All @@ -124,7 +124,7 @@ typedef struct _search_state {
#else
#error "Unknown SIMD Implementation."
#endif /* HAVE_SIMD_NEON */
#endif /* JSON_ENABLE_SIMD */
#endif /* HAVE_SIMD */
} search_state;

#if (defined(__GNUC__ ) || defined(__clang__))
Expand Down Expand Up @@ -261,7 +261,7 @@ static inline void escape_UTF8_char(search_state *search, unsigned char ch_len)
search->cursor = (search->ptr += ch_len);
}

#ifdef JSON_ENABLE_SIMD
#ifdef HAVE_SIMD

static inline FORCE_INLINE char *copy_remaining_bytes(search_state *search, unsigned long vec_len, unsigned long len)
{
Expand Down Expand Up @@ -533,7 +533,7 @@ static inline TARGET_SSE2 FORCE_INLINE unsigned char search_escape_basic_sse2(se

#endif /* HAVE_SIMD_SSE2 */

#endif /* JSON_ENABLE_SIMD */
#endif /* HAVE_SIMD */

static const unsigned char script_safe_escape_table[256] = {
// ASCII Control Characters
Expand Down Expand Up @@ -1298,11 +1298,11 @@ static void generate_json_string(FBuffer *buffer, struct generate_json_data *dat
search.cursor = search.ptr;
search.end = search.ptr + len;

#ifdef JSON_ENABLE_SIMD
#ifdef HAVE_SIMD
search.matches_mask = 0;
search.has_matches = false;
search.chunk_base = NULL;
#endif /* JSON_ENABLE_SIMD */
#endif /* HAVE_SIMD */

switch(rb_enc_str_coderange(obj)) {
case ENC_CODERANGE_7BIT:
Expand Down Expand Up @@ -2170,7 +2170,7 @@ void Init_generator(void)


switch(find_simd_implementation()) {
#ifdef JSON_ENABLE_SIMD
#ifdef HAVE_SIMD
#ifdef HAVE_SIMD_NEON
case SIMD_NEON:
search_escape_basic_impl = search_escape_basic_neon;
Expand All @@ -2181,7 +2181,7 @@ void Init_generator(void)
search_escape_basic_impl = search_escape_basic_sse2;
break;
#endif /* HAVE_SIMD_SSE2 */
#endif /* JSON_ENABLE_SIMD */
#endif /* HAVE_SIMD */
default:
search_escape_basic_impl = search_escape_basic;
break;
Expand Down
2 changes: 2 additions & 0 deletions ext/json/ext/generator/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static SIMD_Implementation find_simd_implementation(void) {
return SIMD_NEON;
}

#define HAVE_SIMD 1
#define HAVE_SIMD_NEON 1

uint8x16x4_t load_uint8x16_4(const unsigned char *table) {
Expand All @@ -74,6 +75,7 @@ uint8x16x4_t load_uint8x16_4(const unsigned char *table) {
#ifdef HAVE_X86INTRIN_H
#include <x86intrin.h>

#define HAVE_SIMD 1
#define HAVE_SIMD_SSE2 1

#ifdef HAVE_CPUID_H
Expand Down