From 850f709a10dc63683725131e517729718e9a49d5 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 30 Aug 2026 23:50:22 +0100 Subject: [PATCH] Update Murmur3 hasher IO --- src/base/hash/hasher/murmur3.c | 4 ++-- src/base/hash/hasher/murmur3.h | 5 ++--- tests/hasher/test_hasher.c | 6 +++--- tests/hasher/test_hasher.cc | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/base/hash/hasher/murmur3.c b/src/base/hash/hasher/murmur3.c index b581baf..fc4985c 100644 --- a/src/base/hash/hasher/murmur3.c +++ b/src/base/hash/hasher/murmur3.c @@ -90,8 +90,8 @@ void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) { h1 += h2; h2 += h1; - io->out_hash1 = h1; - io->out_hash2 = h2; + io->hash[0] = h1; + io->hash[1] = h2; } wp_intern inline u64 fmix64(u64 k) { diff --git a/src/base/hash/hasher/murmur3.h b/src/base/hash/hasher/murmur3.h index dfc8d38..bc3818f 100644 --- a/src/base/hash/hasher/murmur3.h +++ b/src/base/hash/hasher/murmur3.h @@ -19,14 +19,13 @@ BEGIN_C_LINKAGE #define WP_MUR3_HASHER_MAGIC ((u64)0x57504d4841534833) typedef struct { + u64 hash[2]; u64 magic; - u64 out_hash1; - u64 out_hash2; u32 seed; } WpMur3HasherIO; #ifdef WP_PLATFORM_CPP -#define wpMur3HasherIO(SEED) (WpMur3HasherIO{WP_MUR3_HASHER_MAGIC, 0, 0, SEED}) +#define wpMur3HasherIO(SEED) (WpMur3HasherIO{{}, WP_MUR3_HASHER_MAGIC, SEED}) #else #define wpMur3HasherIO(SEED) ((WpMur3HasherIO){ .magic = WP_MUR3_HASHER_MAGIC, .seed = SEED }) #endif diff --git a/tests/hasher/test_hasher.c b/tests/hasher/test_hasher.c index 8c390d6..646021d 100644 --- a/tests/hasher/test_hasher.c +++ b/tests/hasher/test_hasher.c @@ -23,19 +23,19 @@ WpTestFuncResult test_murmur3(void) { wpX64Mur3Hasher128(&str_bytes, (void *)&io); MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; // Array hash wpX64Mur3Hasher128(&arr_bytes, (void *)&io); MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; // Number hash wpX64Mur3Hasher128(&num_bytes, (void *)&io); MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; return wpTesterResult(result); } diff --git a/tests/hasher/test_hasher.cc b/tests/hasher/test_hasher.cc index 8c390d6..646021d 100644 --- a/tests/hasher/test_hasher.cc +++ b/tests/hasher/test_hasher.cc @@ -23,19 +23,19 @@ WpTestFuncResult test_murmur3(void) { wpX64Mur3Hasher128(&str_bytes, (void *)&io); MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; // Array hash wpX64Mur3Hasher128(&arr_bytes, (void *)&io); MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; // Number hash wpX64Mur3Hasher128(&num_bytes, (void *)&io); MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, io.seed, (void *)hash); - result = result && io.out_hash1 == hash[0] && io.out_hash2 == hash[1]; + result = result && io.hash[0] == hash[0] && io.hash[1] == hash[1]; return wpTesterResult(result); }