Skip to content

Commit 8c6403b

Browse files
committed
cpu/aarch64/windows: Use libstd instead of windows_sys.
Eliminate the windows-sys dependency on Aarch64. We believe there is no use for `no_std` support for this target.
1 parent b58c19a commit 8c6403b

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ libc = { version = "0.2.172", default-features = false }
165165
[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_vendor = "apple", any(target_os = "ios", target_os = "macos", target_os = "tvos", target_os = "visionos", target_os = "watchos")))'.dependencies]
166166
libc = { version = "0.2.172", default-features = false }
167167

168-
[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "windows"))'.dependencies]
169-
windows-sys = { version = "0.60", features = ["Win32_Foundation", "Win32_System_Threading"] }
170-
171168
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
172169
wasm-bindgen-test = { version = "0.3.37", default-features = false, features = ["std"] }
173170

src/cpu/aarch64/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ cfg_if::cfg_if! {
4343
mod linux;
4444
use linux as detect;
4545
} else if #[cfg(target_os = "windows")] {
46-
mod windows;
47-
use windows as detect;
46+
mod std_detect;
47+
use std_detect as detect;
4848
} else {
4949
mod detect {
5050
pub const FORCE_DYNAMIC_DETECTION: u32 = 0;

src/cpu/aarch64/windows.rs renamed to src/cpu/aarch64/std_detect.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1414

1515
use super::{Aes, Neon, PMull, Sha256, CAPS_STATIC};
16-
use windows_sys::Win32::System::Threading::{
17-
IsProcessorFeaturePresent, PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE,
18-
};
16+
17+
extern crate std;
18+
use std::arch::is_aarch64_feature_detected;
1919

2020
pub const FORCE_DYNAMIC_DETECTION: u32 = 0;
2121

@@ -25,12 +25,13 @@ pub fn detect_features() -> u32 {
2525

2626
let mut features = 0;
2727

28-
let result = unsafe { IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) };
29-
30-
if result != 0 {
31-
// These are all covered by one call in Windows
28+
if is_aarch64_feature_detected("aes") {
3229
features |= Aes::mask();
30+
}
31+
if is_aarch64_feature_detected("pmull") {
3332
features |= PMull::mask();
33+
}
34+
if is_aarch64_feature_detected("sha2") {
3435
features |= Sha256::mask();
3536
}
3637

0 commit comments

Comments
 (0)