From 9d52b7805dacba89cca75f5743a84794a51d0281 Mon Sep 17 00:00:00 2001 From: Leonid Evdokimov Date: Thu, 26 Sep 2024 12:18:33 +0300 Subject: [PATCH] polymur: add missing polymur_seed_init() call It fixes arm builds, including macos-14-arm64 polymur Verification value 0xA612032C means that polymur_seed_init() was not called. Currently, polymur is compiled in unconditionally, so it should be initialized unconditionally as well. See #294, #296, #297, #298 and #299. --- Hashes.cpp | 5 +++-- Hashes.h | 5 +---- main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Hashes.cpp b/Hashes.cpp index 07cf649e..c33ae593 100644 --- a/Hashes.cpp +++ b/Hashes.cpp @@ -1341,11 +1341,12 @@ void khashv32_test ( const void *key, int len, uint32_t seed, void *out) { } #endif // HAVE_KHASHV -PolymurHashParams g_polymurhashparams = { +#include "polymur-hash/polymur-hash.h" +static PolymurHashParams g_polymurhashparams = { UINT64_C(2172266433527442278), UINT64_C(706663945032637854), UINT64_C(754693428422558902), UINT64_C(9067629717964434866) }; -void polymur_seed_init (size_t &seed) { +void polymur_seed_init (size_t seed) { polymur_init_params_from_seed(&g_polymurhashparams, UINT64_C(0xfedbca9876543210) ^ seed); } diff --git a/Hashes.h b/Hashes.h index 5cd30f3c..006e702a 100644 --- a/Hashes.h +++ b/Hashes.h @@ -1396,12 +1396,9 @@ void khashv32_test ( const void *key, int len, uint32_t seed, void *out); void khashv64_test ( const void *key, int len, uint32_t seed, void *out); #endif -#include "polymur-hash/polymur-hash.h" -extern PolymurHashParams g_polymurhashparams; -void polymur_seed_init (size_t &seed); +void polymur_seed_init (size_t seed); void polymur_test ( const void *key, int len, uint32_t seed, void *out); - /* This version of CRC64 can approach HW crc speeds without hardware support, and can be applied to any polynomial. */ #include "crc64.h" diff --git a/main.cpp b/main.cpp index f9bd65e5..8947b3c7 100644 --- a/main.cpp +++ b/main.cpp @@ -939,13 +939,13 @@ bool Hash_Seed_init (pfHash hash, size_t seed) { else if(hash == hashx_test) hashx_seed_init(info, seed); */ - else if(hash == polymur_test) - polymur_seed_init(seed); # ifdef HAVE_KHASHV else if(hash == khashv64_test || hash == khashv32_test) khashv_seed_init(seed); # endif #endif + else if(hash == polymur_test) + polymur_seed_init(seed); else return false; return true;