xxhash_rust/
xxh64_common.rs1#![allow(unused)]
2
3use core::mem;
4
5pub const CHUNK_SIZE: usize = mem::size_of::<u64>() * 4;
6pub const PRIME_1: u64 = 0x9E3779B185EBCA87;
7pub const PRIME_2: u64 = 0xC2B2AE3D27D4EB4F;
8pub const PRIME_3: u64 = 0x165667B19E3779F9;
9pub const PRIME_4: u64 = 0x85EBCA77C2B2AE63;
10pub const PRIME_5: u64 = 0x27D4EB2F165667C5;
11
12#[inline]
13pub const fn round(acc: u64, input: u64) -> u64 {
14 acc.wrapping_add(input.wrapping_mul(PRIME_2))
15 .rotate_left(31)
16 .wrapping_mul(PRIME_1)
17}
18
19#[inline]
20pub const fn merge_round(mut acc: u64, val: u64) -> u64 {
21 acc ^= round(0, val);
22 acc.wrapping_mul(PRIME_1).wrapping_add(PRIME_4)
23}
24
25#[inline]
26pub const fn avalanche(mut input: u64) -> u64 {
27 input ^= input >> 33;
28 input = input.wrapping_mul(PRIME_2);
29 input ^= input >> 29;
30 input = input.wrapping_mul(PRIME_3);
31 input ^= input >> 32;
32 input
33}