From 285d82ff2c0ae5f616527ec12a471cbda13fa9d7 Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Thu, 12 Dec 2024 08:22:20 +0100 Subject: [PATCH] halftime_hash broke with MSVC --- Hashes.cpp | 4 ++++ Hashes.h | 2 ++ main.cpp | 21 ++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Hashes.cpp b/Hashes.cpp index f02bbb53..b9aac7e2 100644 --- a/Hashes.cpp +++ b/Hashes.cpp @@ -836,6 +836,8 @@ void clhash_seed_init(size_t &seed) #endif +#ifndef _MSC_VER +// FIXME stopped working on MSVC #include "halftime-hash.hpp" alignas(64) static uint64_t @@ -962,6 +964,8 @@ void halftime_hash_seed_init(size_t &seed) } #endif +#endif // !_MSC_VER + // Multiply shift from // Thorup "High Speed Hashing for Integers and Strings" 2018 diff --git a/Hashes.h b/Hashes.h index 5c5fda63..d3617db4 100644 --- a/Hashes.h +++ b/Hashes.h @@ -563,6 +563,7 @@ void clhash_seed_init(size_t &seed); void clhash_test (const void * key, int len, uint32_t seed, void * out); #endif +#ifndef _MSC_VER // objsize 454880-4554f3: 2911 void halftime_hash_style64_test(const void *key, int len, uint32_t seed, void *out); // 455e90 - 45682e: 2462 @@ -573,6 +574,7 @@ void halftime_hash_style256_test(const void *key, int len, uint32_t seed, void * void halftime_hash_style512_test(const void *key, int len, uint32_t seed, void *out); void halftime_hash_init(); void halftime_hash_seed_init(size_t &seed); +#endif #ifdef __SIZEOF_INT128__ void multiply_shift_init(); diff --git a/main.cpp b/main.cpp index 65401c80..8cb88edc 100644 --- a/main.cpp +++ b/main.cpp @@ -698,6 +698,7 @@ HashInfo g_hashes[] = { umash, 64, 0x161495C6, "umash64", "umash 64", GOOD, {} }, { umash128, 128, 0x36D4EC95, "umash128", "umash 128", GOOD, {} }, #endif +#ifndef _MSC_VER { halftime_hash_style64_test, 64, 0x0, "halftime_hash64", "NH tree hash variant", GOOD, {0xc61d672b, 0xcc70c4c1798e4a6f, 0xd3833e804f4c574b, 0xecfc1357d65941ae, 0xbe1927f97b8c43f1, 0xf4d4beb14ae042bbULL, 0x9a9b4c4e44dd48d1ULL} }, // not vulnerable @@ -710,7 +711,7 @@ HashInfo g_hashes[] = { halftime_hash_style512_test, 64, 0x0, "halftime_hash512", "NH tree hash variant", GOOD, {0xc61d672b, 0xcc70c4c1798e4a6f, 0xd3833e804f4c574b, 0xecfc1357d65941ae, 0xbe1927f97b8c43f1, 0xf4d4beb14ae042bbULL, 0x9a9b4c4e44dd48d1ULL} }, - +#endif { t1ha2_atonce_test, 64, 0x8F16C948, "t1ha2_atonce", "Fast Positive Hash (portable", GOOD, { } }, { t1ha2_stream_test, 64, 0xDED9B580, "t1ha2_stream", "Fast Positive Hash (portable)", POOR, {} }, @@ -827,11 +828,13 @@ void Hash_init (HashInfo* info) { #endif else if(info->hash == chaskey_test) chaskey_init(); +#ifndef _MSC_VER else if (info->hash == halftime_hash_style64_test || info->hash == halftime_hash_style128_test || info->hash == halftime_hash_style256_test || info->hash == halftime_hash_style512_test) halftime_hash_init(); +#endif } // optional hash seed initializers. @@ -920,9 +923,11 @@ bool Hash_Seed_init (pfHash hash, size_t seed) { #if defined(HAVE_SSE42) && defined(__x86_64__) else if (hash == clhash_test) clhash_seed_init(seed); +#ifndef _MSC_VER else if (hash == halftime_hash_style64_test || hash == halftime_hash_style128_test || hash == halftime_hash_style256_test || hash == halftime_hash_style512_test) halftime_hash_seed_init(seed); +#endif /* else if(hash == hashx_test) hashx_seed_init(info, seed); @@ -1749,12 +1754,14 @@ void test ( hashfunc hash, HashInfo* info ) bool result = true; bool dumpCollisions = g_drawDiagram; // from --verbose int reps = 1000; - if ((g_speed > 500.0 || info->hashbits > 128 || - hash == o1hash_test || - hash == halftime_hash_style64_test || - hash == halftime_hash_style128_test || - hash == halftime_hash_style256_test || - hash == halftime_hash_style512_test + if ((g_speed > 500.0 || info->hashbits > 128 + || hash == o1hash_test +#ifndef _MSC_VER + || hash == halftime_hash_style64_test + || hash == halftime_hash_style128_test + || hash == halftime_hash_style256_test + || hash == halftime_hash_style512_test +#endif ) && !g_testExtra) reps = 100; // sha1: 7m, md5: 4m53