From ba124757c419aef38019ee7825c32af540b9dcd0 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 4 Nov 2024 15:26:54 +1100 Subject: [PATCH] hashes: Default to no_std `hashes` is `no_std` ready, lets default to `no_std`. --- hashes/src/lib.rs | 5 ++++- hashes/src/sha256.rs | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 00ca7fd70..cc5d191bc 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -50,7 +50,7 @@ //! # } //! ``` -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(bench, feature(test))] @@ -70,6 +70,9 @@ extern crate alloc; extern crate core; +#[cfg(feature = "std")] +extern crate std; + #[cfg(feature = "bitcoin-io")] extern crate bitcoin_io as io; diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 6cdad22c9..42fe5cf24 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -491,10 +491,10 @@ impl HashEngine { fn process_block(&mut self) { #[cfg(all(feature = "std", any(target_arch = "x86", target_arch = "x86_64")))] { - if is_x86_feature_detected!("sse4.1") - && is_x86_feature_detected!("sha") - && is_x86_feature_detected!("sse2") - && is_x86_feature_detected!("ssse3") + if std::is_x86_feature_detected!("sse4.1") + && std::is_x86_feature_detected!("sha") + && std::is_x86_feature_detected!("sse2") + && std::is_x86_feature_detected!("ssse3") { return unsafe { self.process_block_simd_x86_intrinsics() }; }