1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
diff --git a/benches/bench.rs b/benches/bench.rs
index 6189500..3000291 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -66,6 +66,7 @@ bencher::benchmark_group!(
bench_kilobyte_baseline,
bench_megabyte_baseline
);
+#[cfg(feature = "std")]
bencher::benchmark_group!(
bench_specialized,
bench_kilobyte_specialized,
@@ -77,4 +78,7 @@ bencher::benchmark_group!(
bench_combine_32,
bench_combine_64
);
+#[cfg(feature = "std")]
bencher::benchmark_main!(bench_baseline, bench_specialized, bench_combine);
+#[cfg(not(feature = "std"))]
+benchmark_main!(bench_baseline);
diff --git a/src/baseline.rs b/src/baseline.rs
index 38376c7..bb96578 100644
--- a/src/baseline.rs
+++ b/src/baseline.rs
@@ -70,6 +70,9 @@ pub(crate) fn update_slow(prev: u32, buf: &[u8]) -> u32 {
#[cfg(test)]
mod test {
+ #[cfg(not(feature = "std"))]
+ use alloc::vec::Vec;
+
#[test]
fn slow() {
assert_eq!(super::update_slow(0, b""), 0);
diff --git a/src/lib.rs b/src/lib.rs
index 1a4f591..88c7b87 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,6 +39,9 @@
use core::fmt;
use core::hash;
+#[cfg(all(test,not(feature = "std")))]
+extern crate alloc;
+
mod baseline;
mod combine;
mod specialized;
@@ -181,6 +184,9 @@ impl hash::Hasher for Hasher {
mod test {
use super::Hasher;
+ #[cfg(not(feature = "std"))]
+ use alloc::vec::Vec;
+
quickcheck::quickcheck! {
fn combine(bytes_1: Vec<u8>, bytes_2: Vec<u8>) -> bool {
let mut hash_a = Hasher::new();
diff --git a/src/specialized/pclmulqdq.rs b/src/specialized/pclmulqdq.rs
index 18a25ae..a6888a5 100644
--- a/src/specialized/pclmulqdq.rs
+++ b/src/specialized/pclmulqdq.rs
@@ -186,6 +186,7 @@ unsafe fn get(a: &mut &[u8]) -> arch::__m128i {
#[cfg(test)]
mod test {
+ #[cfg(feature = "std")]
quickcheck::quickcheck! {
fn check_against_baseline(init: u32, chunks: Vec<(Vec<u8>, usize)>) -> bool {
let mut baseline = super::super::super::baseline::State::new(init);
|