Skip to content
Merged
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
29 changes: 28 additions & 1 deletion Cargo.lock

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

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ 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 = "aarch64", target_os = "windows"))'.dependencies]
windows-link = { version = "0.2.1" }

[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 Expand Up @@ -236,10 +236,13 @@ overflow-checks = true

[workspace]
members = [
# intentionally not a default member so that `cargo test` doesn't cause criterion.rs and all its
# Not a default member so that `cargo test` doesn't cause criterion.rs and all its
# dependencies to get built.
"bench",

# Not a defailt member as we regenerate bindings manually.
"build/bindgen",

"cavp",
]
default-members = [
Expand Down
11 changes: 11 additions & 0 deletions build/bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "ring-bindgen"
edition = "2024"
publish = false
version = "0.1.0"

[[bin]]
name = "bindgen"

[dependencies]
windows-bindgen = "0.66"
14 changes: 14 additions & 0 deletions build/bindgen/src/bin/bindgen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Run `cargo run -p ring-bindgen` in the Cargo workspace root directory.

fn main() {
windows_bindgen::bindgen([
"--out",
"src/polyfill/aarch64_windows.rs",
"--sys",
"--no-deps",
"--filter",
"IsProcessorFeaturePresent",
"PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE",
])
.unwrap()
}
2 changes: 1 addition & 1 deletion src/cpu/aarch64/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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::{
use crate::polyfill::aarch64_windows::Windows::Win32::System::Threading::{
IsProcessorFeaturePresent, PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE,
};

Expand Down
22 changes: 22 additions & 0 deletions src/polyfill/aarch64_windows.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Bindings generated by `windows-bindgen` 0.66.0

#![allow(
non_snake_case,
non_upper_case_globals,
non_camel_case_types,
dead_code,
clippy::all
)]

pub type BOOL = i32;
pub mod Windows {
pub mod Win32 {
pub mod System {
pub mod Threading {
windows_link::link!("kernel32.dll" "system" fn IsProcessorFeaturePresent(processorfeature : PROCESSOR_FEATURE_ID) -> super::super::super::super::BOOL);
pub const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE: PROCESSOR_FEATURE_ID = 30u32;
pub type PROCESSOR_FEATURE_ID = u32;
}
}
}
}
3 changes: 3 additions & 0 deletions src/polyfill/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ mod test;
pub(crate) mod uninit;
mod uninit_slice;

#[cfg(all(target_arch = "aarch64", target_os = "windows"))]
pub(crate) mod aarch64_windows;

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

#[allow(unused_imports)]
Expand Down