You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
270 lines
8.4 KiB
270 lines
8.4 KiB
From 426384ce34cf410d892eeeeeb7f6046d52bff8e7 Mon Sep 17 00:00:00 2001
|
|
From: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
|
|
Date: Sat, 11 Jul 2020 17:15:56 -0700
|
|
Subject: [PATCH] Add support for ahash
|
|
|
|
---
|
|
CMakeLists.txt | 1 +
|
|
Hashes.h | 5 +++++
|
|
ahash.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
|
main.cpp | 2 +-
|
|
4 files changed, 55 insertions(+), 1 deletion(-)
|
|
create mode 100644 ahash.h
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 6ebab1a..9d79e98 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -470,10 +470,11 @@ add_executable(
|
|
target_link_libraries(
|
|
SMHasher
|
|
SMHasherSupport
|
|
${HIGHWAY_LIB}
|
|
${BLAKE3_LIB}
|
|
+ libahash_c.a
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
)
|
|
|
|
#add_executable(
|
|
# bittest
|
|
diff --git a/Hashes.h b/Hashes.h
|
|
index 4e111c1..fcd3e38 100644
|
|
--- a/Hashes.h
|
|
+++ b/Hashes.h
|
|
@@ -19,10 +19,11 @@
|
|
#if defined(__SSE4_2__) && defined(__x86_64__)
|
|
#include "metrohash/metrohash64crc.h"
|
|
#include "metrohash/metrohash128crc.h"
|
|
#endif
|
|
|
|
+#include "ahash.h"
|
|
#include "fasthash.h"
|
|
#include "jody_hash32.h"
|
|
#include "jody_hash64.h"
|
|
|
|
// objsize: 0-0x113 = 276
|
|
@@ -356,10 +357,14 @@ inline void fasthash32_test ( const void * key, int len, uint32_t seed, void * o
|
|
}
|
|
#ifdef HAVE_INT64
|
|
inline void fasthash64_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
*(uint64_t*)out = fasthash64(key, (size_t) len, (uint64_t)seed);
|
|
}
|
|
+inline void ahash64_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
+ *(uint64_t*)out = ahash64(key, (size_t) len, (uint64_t)seed);
|
|
+}
|
|
+
|
|
#endif
|
|
|
|
// objsize 0-778: 1912
|
|
void mum_hash_test(const void * key, int len, uint32_t seed, void * out);
|
|
|
|
diff --git a/ahash.h b/ahash.h
|
|
new file mode 100644
|
|
index 0000000..6c59caf
|
|
--- /dev/null
|
|
+++ b/ahash.h
|
|
@@ -0,0 +1,48 @@
|
|
+/* The MIT License
|
|
+
|
|
+ Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
|
|
+
|
|
+ Permission is hereby granted, free of charge, to any person
|
|
+ obtaining a copy of this software and associated documentation
|
|
+ files (the "Software"), to deal in the Software without
|
|
+ restriction, including without limitation the rights to use, copy,
|
|
+ modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
+ of the Software, and to permit persons to whom the Software is
|
|
+ furnished to do so, subject to the following conditions:
|
|
+
|
|
+ The above copyright notice and this permission notice shall be
|
|
+ included in all copies or substantial portions of the Software.
|
|
+
|
|
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
+ SOFTWARE.
|
|
+*/
|
|
+
|
|
+#ifndef _AHASH_H
|
|
+#define _AHASH_H
|
|
+
|
|
+#include <stdint.h>
|
|
+#include <stdio.h>
|
|
+
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif
|
|
+
|
|
+/**
|
|
+ * Ahash - 64-bit implementation of aHash
|
|
+ * @buf: data buffer
|
|
+ * @len: data size
|
|
+ * @seed: the seed
|
|
+ */
|
|
+ uint64_t ahash64(const void *buf, size_t len, uint64_t seed);
|
|
+
|
|
+#ifdef __cplusplus
|
|
+}
|
|
+#endif
|
|
+
|
|
+#endif
|
|
\ No newline at end of file
|
|
diff --git a/main.cpp b/main.cpp
|
|
index 04060f2..7489aaf 100644
|
|
--- a/main.cpp
|
|
+++ b/main.cpp
|
|
@@ -263,11 +263,11 @@ HashInfo g_hashes[] =
|
|
|
|
{ xxh3_test, 64, 0x39CD9E4A, "xxh3", "xxHash v3, 64-bit", GOOD },
|
|
{ xxh3low_test, 32, 0xFAE8467B, "xxh3low", "xxHash v3, 64-bit, low 32-bits part", GOOD },
|
|
{ xxh128_test, 128, 0xEB61B3A0, "xxh128", "xxHash v3, 128-bit", GOOD },
|
|
{ xxh128low_test, 64, 0x54D1CC70, "xxh128low", "xxHash v3, 128-bit, low 64-bits part", GOOD },
|
|
-
|
|
+ { ahash64_test, 64, 0x00000000, "ahash64", "ahash 64bit", GOOD }, //Expected value set to zero because aHash does not adhere to a fixed output.
|
|
#if __WORDSIZE >= 64
|
|
# define TIFU_VERIF 0x644236D4
|
|
#else
|
|
// broken on certain travis
|
|
# define TIFU_VERIF 0x0
|
|
--
|
|
2.25.1
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index e4658a7..efef724 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -630,20 +630,21 @@ if(ipo_supported)
|
|
set_property(TARGET SMHasherSupport PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
|
True)
|
|
set_property(TARGET SMHasher PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLTO")
|
|
# set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS "-DLTO")
|
|
else()
|
|
message(STATUS "IPO / LTO not supported: <${error}>")
|
|
endif()
|
|
|
|
target_link_libraries(SMHasher SMHasherSupport ${HIGHWAY_LIB} ${BLAKE3_LIB}
|
|
+ libahash_c.a
|
|
${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
# add_executable( bittest bittest.cpp )
|
|
#
|
|
# target_link_libraries( bittest SMHasherSupport ${CMAKE_THREAD_LIBS_INIT} )
|
|
|
|
if(NOT (CMAKE_CROSSCOMPILING))
|
|
enable_testing()
|
|
add_test(VerifyAll SMHasher --test=VerifyAll)
|
|
add_test(Sanity SMHasher --test=Sanity)
|
|
diff --git a/Hashes.h b/Hashes.h
|
|
index f795403..036b49b 100644
|
|
--- a/Hashes.h
|
|
+++ b/Hashes.h
|
|
@@ -14,20 +14,21 @@
|
|
#include "metrohash/metrohash64.h"
|
|
#include "metrohash/metrohash128.h"
|
|
#include "cmetrohash.h"
|
|
#include "opt_cmetrohash.h"
|
|
|
|
#if defined(__SSE4_2__) && defined(__x86_64__)
|
|
#include "metrohash/metrohash64crc.h"
|
|
#include "metrohash/metrohash128crc.h"
|
|
#endif
|
|
|
|
+#include "ahash.h"
|
|
#include "fasthash.h"
|
|
#include "jody_hash32.h"
|
|
#include "jody_hash64.h"
|
|
|
|
// objsize: 0-0x113 = 276
|
|
#include "tifuhash.h"
|
|
// objsize: 5f0-85f = 623
|
|
#include "floppsyhash.h"
|
|
|
|
#include "vmac.h"
|
|
@@ -353,20 +354,24 @@ inline void cmetrohash64_2_test ( const void * key, int len, uint32_t seed, void
|
|
}
|
|
#endif
|
|
|
|
inline void fasthash32_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
*(uint32_t*)out = fasthash32(key, (size_t) len, seed);
|
|
}
|
|
#ifdef HAVE_INT64
|
|
inline void fasthash64_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
*(uint64_t*)out = fasthash64(key, (size_t) len, (uint64_t)seed);
|
|
}
|
|
+
|
|
+inline void ahash64_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
+ *(uint64_t*)out = ahash64(key, (size_t) len, (uint64_t)seed);
|
|
+}
|
|
#endif
|
|
|
|
// objsize 0-778: 1912
|
|
void mum_hash_test(const void * key, int len, uint32_t seed, void * out);
|
|
|
|
inline void mum_low_test ( const void * key, int len, uint32_t seed, void * out ) {
|
|
uint64_t result;
|
|
mum_hash_test(key, len, seed, &result);
|
|
*(uint32_t*)out = (uint32_t)result;
|
|
}
|
|
diff --git a/ahash.h b/ahash.h
|
|
new file mode 100644
|
|
index 0000000..2ed416d
|
|
--- /dev/null
|
|
+++ b/ahash.h
|
|
@@ -0,0 +1,24 @@
|
|
+
|
|
+#ifndef _AHASH_H
|
|
+#define _AHASH_H
|
|
+
|
|
+#include <stdint.h>
|
|
+#include <stdio.h>
|
|
+
|
|
+#ifdef __cplusplus
|
|
+extern "C" {
|
|
+#endif
|
|
+
|
|
+/**
|
|
+ * Ahash - 64-bit implementation of aHash
|
|
+ * @buf: data buffer
|
|
+ * @len: data size
|
|
+ * @seed: the seed
|
|
+ */
|
|
+ uint64_t ahash64(const void *buf, size_t len, uint64_t seed);
|
|
+
|
|
+#ifdef __cplusplus
|
|
+}
|
|
+#endif
|
|
+
|
|
+#endif
|
|
\ No newline at end of file
|
|
diff --git a/main.cpp b/main.cpp
|
|
index f742fbf..c221f7d 100644
|
|
--- a/main.cpp
|
|
+++ b/main.cpp
|
|
@@ -434,20 +434,21 @@ HashInfo g_hashes[] =
|
|
{ t1ha0_ia32aes_avx1_test, 64, 0xF07C4DA5, "t1ha0_aes_avx1", "Fast Positive Hash (machine-specific, requires AES-NI & AVX)", GOOD },
|
|
# endif /* __AVX__ */
|
|
# if defined(__AVX2__)
|
|
{ t1ha0_ia32aes_avx2_test, 64, 0x8B38C599, "t1ha0_aes_avx2", "Fast Positive Hash (machine-specific, requires AES-NI & AVX2)", GOOD },
|
|
# endif /* __AVX2__ */
|
|
#endif /* T1HA0_AESNI_AVAILABLE */
|
|
{ xxh3_test, 64, 0x39CD9E4A, "xxh3", "xxHash v3, 64-bit", GOOD },
|
|
{ xxh3low_test, 32, 0xFAE8467B, "xxh3low", "xxHash v3, 64-bit, low 32-bits part", GOOD },
|
|
{ xxh128_test, 128, 0xEB61B3A0, "xxh128", "xxHash v3, 128-bit", GOOD },
|
|
{ xxh128low_test, 64, 0x54D1CC70, "xxh128low", "xxHash v3, 128-bit, low 64-bits part", GOOD },
|
|
+ { ahash64_test, 64, 0x00000000, "ahash64", "ahash 64bit", GOOD }, //Expected value set to zero because aHash does not adhere to a fixed output.
|
|
#ifdef HAVE_BIT32
|
|
{ wyhash32_test, 32, 0x09DE8066, "wyhash32", "wyhash (32-bit)", GOOD },
|
|
#else
|
|
{ wyhash32low, 32, 0x9241B8A3, "wyhash32low", "wyhash lower 32bit", GOOD },
|
|
#endif
|
|
#ifdef HAVE_INT64
|
|
{ wyhash_test, 64, 0x7C62138D, "wyhash", "wyhash (64-bit)", GOOD },
|
|
#endif
|
|
|
|
};
|