Skip to content

Commit f1776e8

Browse files
byrootmatzbot
authored andcommitted
[ruby/json] Tentative fix for RHEL8 compiler
``` parser.c:87:77: error: missing binary operator before token "(" #if JSON_CPU_LITTLE_ENDIAN_64BITS && defined(__has_builtin) && __has_builtin(__builtin_bswap64) ``` ruby/json@fce1c7e84a
1 parent 7c92401 commit f1776e8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ext/json/parser/parser.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ static void rvalue_cache_insert_at(rvalue_cache *cache, int index, VALUE rstring
8484
cache->entries[index] = rstring;
8585
}
8686

87-
#if JSON_CPU_LITTLE_ENDIAN_64BITS && defined(__has_builtin) && __has_builtin(__builtin_bswap64)
87+
#define rstring_cache_memcmp memcmp
88+
89+
#if JSON_CPU_LITTLE_ENDIAN_64BITS
90+
#if __has_builtin(__builtin_bswap64)
91+
#undef rstring_cache_memcmp
8892
static ALWAYS_INLINE() int rstring_cache_memcmp(const char *str, const char *rptr, const long length)
8993
{
9094
// The libc memcmp has numerous complex optimizations, but in this particular case,
@@ -111,8 +115,7 @@ static ALWAYS_INLINE() int rstring_cache_memcmp(const char *str, const char *rpt
111115

112116
return 0;
113117
}
114-
#else
115-
#define rstring_cache_memcmp memcmp
118+
#endif
116119
#endif
117120

118121
static ALWAYS_INLINE() int rstring_cache_cmp(const char *str, const long length, VALUE rstring)

ext/json/simd/simd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ typedef enum {
66
SIMD_SSE2
77
} SIMD_Implementation;
88

9+
#ifndef __has_builtin // Optional of course.
10+
#define __has_builtin(x) 0 // Compatibility with non-clang compilers.
11+
#endif
12+
913
#ifdef __clang__
1014
# if __has_builtin(__builtin_ctzll)
1115
# define HAVE_BUILTIN_CTZLL 1

0 commit comments

Comments
 (0)