1From 426384ce34cf410d892eeeeeb7f6046d52bff8e7 Mon Sep 17 00:00:00 2001 2From: Tom Kaitchuck <Tom.Kaitchuck@gmail.com> 3Date: Sat, 11 Jul 2020 17:15:56 -0700 4Subject: [PATCH] Add support for ahash 5 6--- 7 CMakeLists.txt | 1 + 8 Hashes.h | 5 +++++ 9 ahash.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 10 main.cpp | 2 +- 11 4 files changed, 55 insertions(+), 1 deletion(-) 12 create mode 100644 ahash.h 13 14diff --git a/CMakeLists.txt b/CMakeLists.txt 15index 6ebab1a..9d79e98 100644 16--- a/CMakeLists.txt 17+++ b/CMakeLists.txt 18@@ -470,10 +470,11 @@ add_executable( 19 target_link_libraries( 20 SMHasher 21 SMHasherSupport 22 ${HIGHWAY_LIB} 23 ${BLAKE3_LIB} 24+ libahash_c.a 25 ${CMAKE_THREAD_LIBS_INIT} 26 ) 27 28 #add_executable( 29 # bittest 30diff --git a/Hashes.h b/Hashes.h 31index 4e111c1..fcd3e38 100644 32--- a/Hashes.h 33+++ b/Hashes.h 34@@ -19,10 +19,11 @@ 35 #if defined(__SSE4_2__) && defined(__x86_64__) 36 #include "metrohash/metrohash64crc.h" 37 #include "metrohash/metrohash128crc.h" 38 #endif 39 40+#include "ahash.h" 41 #include "fasthash.h" 42 #include "jody_hash32.h" 43 #include "jody_hash64.h" 44 45 // objsize: 0-0x113 = 276 46@@ -356,10 +357,14 @@ inline void fasthash32_test ( const void * key, int len, uint32_t seed, void * o 47 } 48 #ifdef HAVE_INT64 49 inline void fasthash64_test ( const void * key, int len, uint32_t seed, void * out ) { 50 *(uint64_t*)out = fasthash64(key, (size_t) len, (uint64_t)seed); 51 } 52+inline void ahash64_test ( const void * key, int len, uint32_t seed, void * out ) { 53+ *(uint64_t*)out = ahash64(key, (size_t) len, (uint64_t)seed); 54+} 55+ 56 #endif 57 58 // objsize 0-778: 1912 59 void mum_hash_test(const void * key, int len, uint32_t seed, void * out); 60 61diff --git a/ahash.h b/ahash.h 62new file mode 100644 63index 0000000..6c59caf 64--- /dev/null 65+++ b/ahash.h 66@@ -0,0 +1,48 @@ 67+/* The MIT License 68+ 69+ Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com) 70+ 71+ Permission is hereby granted, free of charge, to any person 72+ obtaining a copy of this software and associated documentation 73+ files (the "Software"), to deal in the Software without 74+ restriction, including without limitation the rights to use, copy, 75+ modify, merge, publish, distribute, sublicense, and/or sell copies 76+ of the Software, and to permit persons to whom the Software is 77+ furnished to do so, subject to the following conditions: 78+ 79+ The above copyright notice and this permission notice shall be 80+ included in all copies or substantial portions of the Software. 81+ 82+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 83+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 84+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 85+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 86+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 87+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 88+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 89+ SOFTWARE. 90+*/ 91+ 92+#ifndef _AHASH_H 93+#define _AHASH_H 94+ 95+#include <stdint.h> 96+#include <stdio.h> 97+ 98+#ifdef __cplusplus 99+extern "C" { 100+#endif 101+ 102+/** 103+ * Ahash - 64-bit implementation of aHash 104+ * @buf: data buffer 105+ * @len: data size 106+ * @seed: the seed 107+ */ 108+ uint64_t ahash64(const void *buf, size_t len, uint64_t seed); 109+ 110+#ifdef __cplusplus 111+} 112+#endif 113+ 114+#endif 115\ No newline at end of file 116diff --git a/main.cpp b/main.cpp 117index 04060f2..7489aaf 100644 118--- a/main.cpp 119+++ b/main.cpp 120@@ -263,11 +263,11 @@ HashInfo g_hashes[] = 121 122 { xxh3_test, 64, 0x39CD9E4A, "xxh3", "xxHash v3, 64-bit", GOOD }, 123 { xxh3low_test, 32, 0xFAE8467B, "xxh3low", "xxHash v3, 64-bit, low 32-bits part", GOOD }, 124 { xxh128_test, 128, 0xEB61B3A0, "xxh128", "xxHash v3, 128-bit", GOOD }, 125 { xxh128low_test, 64, 0x54D1CC70, "xxh128low", "xxHash v3, 128-bit, low 64-bits part", GOOD }, 126- 127+ { ahash64_test, 64, 0x00000000, "ahash64", "ahash 64bit", GOOD }, //Expected value set to zero because aHash does not adhere to a fixed output. 128 #if __WORDSIZE >= 64 129 # define TIFU_VERIF 0x644236D4 130 #else 131 // broken on certain travis 132 # define TIFU_VERIF 0x0 133-- 1342.25.1 135 136