Skip to content

Commit

Permalink
Force miri to use the fallback algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaitchuck committed May 6, 2020
1 parent 7681a46 commit ca2f390
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/aes_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Hasher for AHasher {
}
}

#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2", not(miri)))]
#[inline(always)]
fn add_by_64s(a: u128, b: u128) -> u128 {
use core::mem::transmute;
Expand All @@ -193,7 +193,7 @@ fn add_by_64s(a: u128, b: u128) -> u128 {
}
}

#[cfg(not(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2")))]
#[cfg(not(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2", not(miri))))]
#[inline(always)]
fn add_by_64s(a: u128, b: u128) -> u128 {
let a: [u64; 2] = a.convert();
Expand All @@ -202,7 +202,7 @@ fn add_by_64s(a: u128, b: u128) -> u128 {
c.convert()
}

#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
#[inline(always)]
fn aeshash(value: u128, xor: u128) -> u128 {
#[cfg(target_arch = "x86")]
Expand All @@ -215,7 +215,7 @@ fn aeshash(value: u128, xor: u128) -> u128 {
transmute(_mm_aesdec_si128(value, transmute(xor)))
}
}
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
#[inline(always)]
fn aeshashx2(value: u128, k1: u128, k2: u128) -> u128 {
#[cfg(target_arch = "x86")]
Expand Down
10 changes: 5 additions & 5 deletions src/hash_quality_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ fn count_same_bytes_and_nibbles(a: u64, b: u64) -> (i32, i32) {
}

fn test_keys_change_output<T: Hasher>(constructor: impl Fn(u64, u64) -> T) {
let mut a = constructor(0, 0);
let mut b = constructor(0, 1);
let mut c = constructor(1, 0);
let mut d = constructor(1, 1);
let mut a = constructor(1, 1);
let mut b = constructor(1, 2);
let mut c = constructor(2, 1);
let mut d = constructor(2, 2);

This comment has been minimized.

Copy link
@jonhoo

jonhoo May 6, 2020

These changes seem unrelated?

This comment has been minimized.

Copy link
@tkaitchuck

tkaitchuck May 14, 2020

Author Owner

They are. (It's modifying the test to verify with non-zero keys because it's easier for a test to pass differentiating zero from not zero)

"test".hash(&mut a);
"test".hash(&mut b);
"test".hash(&mut c);
Expand Down Expand Up @@ -263,7 +263,7 @@ mod fallback_tests {
}

///Basic sanity tests of the cypto properties of aHash.
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
#[cfg(test)]
mod aes_tests {
use crate::aes_hash::*;
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#[macro_use]
mod convert;

#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
mod aes_hash;
mod fallback_hash;
#[cfg(test)]
Expand All @@ -33,10 +33,10 @@ mod random_state;
#[cfg(feature = "compile-time-rng")]
use const_random::const_random;

#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes"))]
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri)))]
pub use crate::aes_hash::AHasher;

#[cfg(not(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes")))]
#[cfg(not(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "aes", not(miri))))]
pub use crate::fallback_hash::AHasher;
pub use crate::random_state::RandomState;

Expand Down

0 comments on commit ca2f390

Please sign in to comment.