diff options
Diffstat (limited to 'include/hash.h')
-rw-r--r-- | include/hash.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/include/hash.h b/include/hash.h index f39a8257..5d0512a6 100644 --- a/include/hash.h +++ b/include/hash.h @@ -31,12 +31,12 @@ #ifdef __x86_64__ -#define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r)))) +# define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r)))) static inline u32 hash32(const void* key, u32 len, u32 seed) { const u64* data = (u64*)key; - u64 h1 = seed ^ len; + u64 h1 = seed ^ len; len >>= 3; @@ -45,12 +45,12 @@ static inline u32 hash32(const void* key, u32 len, u32 seed) { u64 k1 = *data++; k1 *= 0x87c37b91114253d5ULL; - k1 = ROL64(k1, 31); + k1 = ROL64(k1, 31); k1 *= 0x4cf5ad432745937fULL; h1 ^= k1; - h1 = ROL64(h1, 27); - h1 = h1 * 5 + 0x52dce729; + h1 = ROL64(h1, 27); + h1 = h1 * 5 + 0x52dce729; } @@ -64,14 +64,14 @@ static inline u32 hash32(const void* key, u32 len, u32 seed) { } -#else +#else -#define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r)))) +# define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r)))) static inline u32 hash32(const void* key, u32 len, u32 seed) { - const u32* data = (u32*)key; - u32 h1 = seed ^ len; + const u32* data = (u32*)key; + u32 h1 = seed ^ len; len >>= 2; @@ -80,12 +80,12 @@ static inline u32 hash32(const void* key, u32 len, u32 seed) { u32 k1 = *data++; k1 *= 0xcc9e2d51; - k1 = ROL32(k1, 15); + k1 = ROL32(k1, 15); k1 *= 0x1b873593; h1 ^= k1; - h1 = ROL32(h1, 13); - h1 = h1 * 5 + 0xe6546b64; + h1 = ROL32(h1, 13); + h1 = h1 * 5 + 0xe6546b64; } @@ -102,3 +102,4 @@ static inline u32 hash32(const void* key, u32 len, u32 seed) { #endif /* ^__x86_64__ */ #endif /* !_HAVE_HASH_H */ + |