@@ -2,14 +2,17 @@
|
|||||||
|
|
||||||
#include "murmur3.h"
|
#include "murmur3.h"
|
||||||
#include "../../../common/aliases/aliases.h"
|
#include "../../../common/aliases/aliases.h"
|
||||||
|
#include "../../../common/assert/assert.h"
|
||||||
#include "../../../common/misc/misc_utils.h"
|
#include "../../../common/misc/misc_utils.h"
|
||||||
|
|
||||||
#define _bigConstant(x) (x##LLU)
|
#define _bigConstant(x) (x##LLU)
|
||||||
|
|
||||||
wp_intern inline u64 fmix64(u64 k);
|
wp_intern inline void _validateIO(const WpMur3HasherIO *io);
|
||||||
|
wp_intern inline u64 _fmix64(u64 k);
|
||||||
|
|
||||||
void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) {
|
void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) {
|
||||||
WpMur3HasherIO *io = (WpMur3HasherIO *)hasher_io;
|
WpMur3HasherIO *io = (WpMur3HasherIO *)hasher_io;
|
||||||
|
_validateIO(io);
|
||||||
|
|
||||||
const i32 nblocks = (bytes->count * bytes->item_size) / 16;
|
const i32 nblocks = (bytes->count * bytes->item_size) / 16;
|
||||||
|
|
||||||
@@ -84,8 +87,8 @@ void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) {
|
|||||||
h1 += h2;
|
h1 += h2;
|
||||||
h2 += h1;
|
h2 += h1;
|
||||||
|
|
||||||
h1 = fmix64(h1);
|
h1 = _fmix64(h1);
|
||||||
h2 = fmix64(h2);
|
h2 = _fmix64(h2);
|
||||||
|
|
||||||
h1 += h2;
|
h1 += h2;
|
||||||
h2 += h1;
|
h2 += h1;
|
||||||
@@ -94,7 +97,11 @@ void wpX64Mur3Hasher128(WpU8Stream *bytes, void *hasher_io) {
|
|||||||
io->hash[1] = h2;
|
io->hash[1] = h2;
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_intern inline u64 fmix64(u64 k) {
|
wp_intern inline void _validateIO(const WpMur3HasherIO *io) {
|
||||||
|
wpRuntimeAssert(io->magic == WP_MUR3_HASHER_MAGIC, "Invalid Murmur3 hash IO");
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_intern inline u64 _fmix64(u64 k) {
|
||||||
k ^= k >> 33;
|
k ^= k >> 33;
|
||||||
k *= _bigConstant(0xff51afd7ed558ccd);
|
k *= _bigConstant(0xff51afd7ed558ccd);
|
||||||
k ^= k >> 33;
|
k ^= k >> 33;
|
||||||
|
|||||||
Reference in New Issue
Block a user