Skip to content

Commit

Permalink
nmhash32: expose compile-time constants in --list
Browse files Browse the repository at this point in the history
  • Loading branch information
darkk authored and rurban committed Sep 28, 2024
1 parent 850e1bd commit 2c86e9a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ SET(exectargets ${exectargets} SMHasher)

if(NOT (CMAKE_CROSSCOMPILING))
enable_testing()
add_test(List SMHasher --list)
add_test(VerifyAll SMHasher --test=VerifyAll)
add_test(Sanity SMHasher --test=Sanity)
add_test(Speed SMHasher --test=Speed)
Expand Down
2 changes: 2 additions & 0 deletions Hashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,8 @@ void crc32c_pclmul_test(const void *key, int len, uint32_t seed, void *out)
#endif

#include "hash-garage/nmhash.h"
const char * const nmhash32_desc("nmhash32, le:" MACRO_ITOA(NMHASH_LITTLE_ENDIAN) ", vector:" MACRO_ITOA(NMH_VECTOR) ", align:" MACRO_ITOA(NMH_ACC_ALIGN));
const char * const nmhash32x_desc("nmhash32x, le:" MACRO_ITOA(NMHASH_LITTLE_ENDIAN) ", vector:" MACRO_ITOA(NMH_VECTOR) ", align:" MACRO_ITOA(NMH_ACC_ALIGN));
// objsize: 4202f0-420c7d: 2445
void nmhash32_test ( const void * key, int len, uint32_t seed, void * out ) {
*(uint32_t*)out = NMHASH32 (key, (const size_t) len, seed);
Expand Down
2 changes: 2 additions & 0 deletions Hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,8 @@ extern "C" {
void asconhashv12_256 ( const void * key, int len, uint32_t seed, void * out );
}

extern const char * const nmhash32_desc;
extern const char * const nmhash32x_desc;
void nmhash32_test ( const void * key, int len, uint32_t seed, void * out );
void nmhash32x_test ( const void * key, int len, uint32_t seed, void * out );

Expand Down
3 changes: 3 additions & 0 deletions Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
using namespace std;
#include <assert.h>

#define MACRO_ITOA_(x) #x
#define MACRO_ITOA(x) MACRO_ITOA_(x)

//-----------------------------------------------------------------------------
// If the optimizer detects that a value in a speed test is constant or unused,
// the optimizer may remove references to it or otherwise create code that
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,8 @@ HashInfo g_hashes[] =
{ rapidhash_test, 64, 0xAF404C4B, "rapidhash", "rapidhash v1", GOOD, {}},
{ rapidhash_unrolled_test, 64, 0xAF404C4B, "rapidhash_unrolled", "rapidhash v1 - unrolled", GOOD, {}},
#endif
{ nmhash32_test, 32, 0x12A30553, "nmhash32", "nmhash32", GOOD, {}},
{ nmhash32x_test, 32, 0xA8580227, "nmhash32x", "nmhash32x", GOOD, {}},
{ nmhash32_test, 32, 0x12A30553, "nmhash32", nmhash32_desc, GOOD, {}},
{ nmhash32x_test, 32, 0xA8580227, "nmhash32x", nmhash32x_desc, GOOD, {}},
#ifdef HAVE_KHASHV
#ifdef __clang__ // also gcc 9.4
#define KHASHV32_VERIF 0xB69DF8EB
Expand Down

0 comments on commit 2c86e9a

Please sign in to comment.