summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-11-04 12:06:46 +0100
committergit <svn-admin@ruby-lang.org>2025-11-04 11:07:31 +0000
commitf1776e8f176f50bd9ab16ca399d1a9c8b7d6eeb7 (patch)
tree1d1d785224410b7cc18d22061b9ff7b1996d05d5
parent7c924013630699321d51438f3754b291d8d4a37e (diff)
[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) ``` https://github.com/ruby/json/commit/fce1c7e84a
-rw-r--r--ext/json/parser/parser.c9
-rw-r--r--ext/json/simd/simd.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 3d88a399e7..9df04ce007 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -84,7 +84,11 @@ static void rvalue_cache_insert_at(rvalue_cache *cache, int index, VALUE rstring
cache->entries[index] = rstring;
}
-#if JSON_CPU_LITTLE_ENDIAN_64BITS && defined(__has_builtin) && __has_builtin(__builtin_bswap64)
+#define rstring_cache_memcmp memcmp
+
+#if JSON_CPU_LITTLE_ENDIAN_64BITS
+#if __has_builtin(__builtin_bswap64)
+#undef rstring_cache_memcmp
static ALWAYS_INLINE() int rstring_cache_memcmp(const char *str, const char *rptr, const long length)
{
// 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
return 0;
}
-#else
-#define rstring_cache_memcmp memcmp
+#endif
#endif
static ALWAYS_INLINE() int rstring_cache_cmp(const char *str, const long length, VALUE rstring)
diff --git a/ext/json/simd/simd.h b/ext/json/simd/simd.h
index a4f917fd0a..c9e3b3ec7c 100644
--- a/ext/json/simd/simd.h
+++ b/ext/json/simd/simd.h
@@ -6,6 +6,10 @@ typedef enum {
SIMD_SSE2
} SIMD_Implementation;
+#ifndef __has_builtin // Optional of course.
+ #define __has_builtin(x) 0 // Compatibility with non-clang compilers.
+#endif
+
#ifdef __clang__
# if __has_builtin(__builtin_ctzll)
# define HAVE_BUILTIN_CTZLL 1