Adapt hash tests to big-endian systems.
The hash code, which has MurmurHash3 at its core, generates different output depending on system endianness, so adapt the expected output on big-endian systems. MurmurHash3 code also makes the assumption that unaligned access is okay (not true on all systems), but jemalloc only hashes data structures that have sufficient alignment to dodge this limitation.
This commit is contained in:
parent
ada8447cf6
commit
df3f27024f
@ -150,6 +150,11 @@ if test "x$EXTRA_CFLAGS" != "x" ; then
|
||||
fi
|
||||
AC_PROG_CPP
|
||||
|
||||
AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0])
|
||||
if test "x${ac_cv_big_endian}" = "x1" ; then
|
||||
AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ])
|
||||
fi
|
||||
|
||||
AC_CHECK_SIZEOF([void *])
|
||||
if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
|
||||
LG_SIZEOF_PTR=3
|
||||
|
@ -320,7 +320,7 @@ hash_x64_128(const void *key, const int len, const uint32_t seed,
|
||||
JEMALLOC_INLINE void
|
||||
hash(const void *key, size_t len, const uint32_t seed, size_t r_hash[2])
|
||||
{
|
||||
#if (LG_SIZEOF_PTR == 3)
|
||||
#if (LG_SIZEOF_PTR == 3 && !defined(JEMALLOC_BIG_ENDIAN))
|
||||
hash_x64_128(key, len, seed, (uint64_t *)r_hash);
|
||||
#else
|
||||
uint64_t hashes[2];
|
||||
|
@ -190,6 +190,9 @@
|
||||
/* C99 restrict keyword supported. */
|
||||
#undef JEMALLOC_HAS_RESTRICT
|
||||
|
||||
/* For use by hash code. */
|
||||
#undef JEMALLOC_BIG_ENDIAN
|
||||
|
||||
/* sizeof(int) == 2^LG_SIZEOF_INT. */
|
||||
#undef LG_SIZEOF_INT
|
||||
|
||||
|
@ -122,9 +122,15 @@ hash_variant_verify(hash_variant_t variant)
|
||||
(final[3] << 24);
|
||||
|
||||
switch (variant) {
|
||||
#ifdef JEMALLOC_BIG_ENDIAN
|
||||
case hash_variant_x86_32: expected = 0x6213303eU; break;
|
||||
case hash_variant_x86_128: expected = 0x266820caU; break;
|
||||
case hash_variant_x64_128: expected = 0xcc622b6fU; break;
|
||||
#else
|
||||
case hash_variant_x86_32: expected = 0xb0f57ee3U; break;
|
||||
case hash_variant_x86_128: expected = 0xb3ece62aU; break;
|
||||
case hash_variant_x64_128: expected = 0x6384ba69U; break;
|
||||
#endif
|
||||
default: not_reached();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user