Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ libc = { version = "0.2.172", default-features = false }
[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]
libc = { version = "0.2.172", default-features = false }

[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "windows"))'.dependencies]
windows-sys = { version = "0.61.2", features = ["Win32_Foundation", "Win32_System_Threading"] }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
wasm-bindgen-test = { version = "0.3.64", default-features = false, features = ["std"] }

Expand Down
8 changes: 4 additions & 4 deletions src/cpu/aarch64/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use super::{Aes, CAPS_STATIC, Neon, PMull, Sha256};
use windows_sys::Win32::System::Threading::{
IsProcessorFeaturePresent, PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE,
};
use crate::polyfill::windows_sys;

pub const FORCE_DYNAMIC_DETECTION: u32 = 0;

Expand All @@ -25,7 +23,9 @@ pub fn detect_features() -> u32 {

let mut features = 0;

let result = unsafe { IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) };
let result = unsafe {
windows_sys::IsProcessorFeaturePresent(windows_sys::PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)
};

if result != 0 {
// These are all covered by one call in Windows
Expand Down
3 changes: 3 additions & 0 deletions src/polyfill/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ mod test;
mod uninit_slice;
mod uninit_slice_cursor;

#[cfg(target_arch = "aarch64")]
pub(crate) mod windows_sys;

pub use self::{array_flat_map::ArrayFlatMap, array_split_map::ArraySplitMap, notsend::NotSend};

#[allow(unused_imports)]
Expand Down
25 changes: 25 additions & 0 deletions src/polyfill/windows_sys.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2016-2025 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

pub type DWORD = u32;
pub type BOOL = i32;

/// This Arm processor implements the Arm v8 extra cryptographic instructions (for example, AES, SHA1 and SHA2).
pub const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE: DWORD = 30;

#[link(name = "kernel32", kind = "raw-dylib")]
extern "system" {
/// <https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent>
fn IsProcessorFeaturePresent(processor_feature: DWORD) -> BOOL;
}