Skip to content

Commit

Permalink
halftime_hash broke with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Dec 12, 2024
1 parent b0e5cfe commit 285d82f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Hashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
21 changes: 14 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, {} },
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1749,12 +1754,14 @@ void test ( hashfunc<hashtype> 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

Expand Down

0 comments on commit 285d82f

Please sign in to comment.