Skip to content

Commit

Permalink
Merge branch 'main' into mem_dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCappelletti94 committed Aug 21, 2024
2 parents ca5d4a2 + 0c9d55e commit 538e68e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/sixty_four.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const PRIME_5: u64 = 2_870_177_450_012_600_261;

#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, Eq, Hash, PartialEq)]
struct XxCore {
v1: u64,
v2: u64,
Expand All @@ -25,7 +25,7 @@ struct XxCore {
/// Calculates the 64-bit hash.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct XxHash64 {
total_len: u64,
seed: u64,
Expand Down Expand Up @@ -124,15 +124,15 @@ impl core::fmt::Debug for XxCore {
}

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, Default, PartialEq)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
#[repr(align(8))]
#[cfg_attr(feature = "serialize", serde(transparent))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
struct AlignToU64<T>(T);

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Debug, Copy, Clone, Default, PartialEq)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
struct Buffer {
#[cfg_attr(feature = "serialize", serde(rename = "buffer"))]
data: AlignToU64<[u8; CHUNK_SIZE]>,
Expand Down
8 changes: 4 additions & 4 deletions src/std_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub mod sixty_four {
use core::hash::BuildHasher;
use rand::{self, Rng};

#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
/// Constructs a randomized seed and reuses it for multiple hasher instances.
pub struct RandomXxHashBuilder64(u64);

Expand Down Expand Up @@ -34,8 +34,8 @@ pub mod thirty_two {
use core::hash::BuildHasher;
use rand::{self, Rng};

#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
/// Constructs a randomized seed and reuses it for multiple hasher instances. See the usage warning on `XxHash32`.
pub struct RandomXxHashBuilder32(u32);

Expand Down Expand Up @@ -65,8 +65,8 @@ pub mod xxh3 {
use core::hash::BuildHasher;
use rand::{self, Rng};

#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
/// Constructs a randomized seed and reuses it for multiple hasher instances.
pub struct RandomHashBuilder64(u64);

Expand All @@ -90,8 +90,8 @@ pub mod xxh3 {
}
}

#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
/// Constructs a randomized seed and reuses it for multiple hasher instances.
pub struct RandomHashBuilder128(u64);

Expand Down
8 changes: 4 additions & 4 deletions src/thirty_two.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const PRIME_5: u32 = 374_761_393;

#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Copy, Clone, PartialEq)]
#[derive(Copy, Clone, PartialEq, Eq)]
struct XxCore {
v1: u32,
v2: u32,
Expand All @@ -30,7 +30,7 @@ struct XxCore {
/// unlikely to be correct to use this in places like a `HashMap`.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct XxHash32 {
total_len: u64,
seed: u32,
Expand Down Expand Up @@ -114,15 +114,15 @@ impl core::fmt::Debug for XxCore {
}

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, Default, PartialEq)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
#[repr(align(4))]
#[cfg_attr(feature = "serialize", serde(transparent))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
struct AlignToU32<T>(T);

#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Debug, Copy, Clone, Default, PartialEq)]
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)]
struct Buffer {
#[cfg_attr(feature = "serialize", serde(rename = "buffer"))]
data: AlignToU32<[u8; CHUNK_SIZE]>,
Expand Down
16 changes: 8 additions & 8 deletions src/xxh3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn hash128_with_secret(data: &[u8], secret: &[u8]) -> u128 {
/// Calculates the 64-bit hash.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Default)]
#[derive(Clone, Default, Eq, PartialEq, Debug)]
pub struct Hash64(State);

impl Hash64 {
Expand Down Expand Up @@ -145,7 +145,7 @@ impl Hasher for Hash64 {
/// Calculates the 128-bit hash.
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Default)]
#[derive(Clone, Default, Eq, PartialEq, Debug)]
pub struct Hash128(State);

impl Hash128 {
Expand Down Expand Up @@ -204,8 +204,8 @@ const SECRET: Secret = Secret([
]);

#[repr(align(64))]
#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone, Eq, PartialEq, Debug)]
struct Secret([u8; SECRET_DEFAULT_SIZE]);

const_assert_eq!(mem::size_of::<Secret>() % 16, 0);
Expand Down Expand Up @@ -293,19 +293,19 @@ cfg_if! {
#[repr(align(32))]
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Acc([u64; ACC_NB]);
} else if #[cfg(target_feature = "sse2")] {
#[repr(align(16))]
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Acc([u64; ACC_NB]);
} else {
#[repr(align(8))]
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Acc([u64; ACC_NB]);
}
}
Expand Down Expand Up @@ -856,7 +856,7 @@ const_assert_eq!(INTERNAL_BUFFER_SIZE % STRIPE_LEN, 0);
#[repr(align(64))]
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone)]
#[derive(Clone, Eq, PartialEq, Debug)]
struct State {
acc: Acc,
secret: With,
Expand All @@ -868,7 +868,7 @@ struct State {

#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
#[derive(Clone)]
#[derive(Clone, Debug, Eq, PartialEq)]
enum With {
Default(Secret),
Custom(Secret),
Expand Down

0 comments on commit 538e68e

Please sign in to comment.