Skip to content

Commit

Permalink
cpu: Expand dynamic detection to all supported OSs on AArch64.
Browse files Browse the repository at this point in the history
  • Loading branch information
briansmith committed Oct 31, 2022
1 parent 90a0843 commit aa15beb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ name = "ring"
getrandom = { version = "0.2.8" }
untrusted = { version = "0.9" }

[target.'cfg(any(target_arch = "x86",target_arch = "x86_64", all(any(target_arch = "aarch64", target_arch = "arm"), any(target_os = "android", target_os = "fuchsia", target_os = "linux", target_os = "windows"))))'.dependencies]
[target.'cfg(any(target_arch = "x86",target_arch = "x86_64", all(target_arch = "aarch64", any(target_family = "unix", target_family = "windows")), all(target_arch = "arm", any(target_os = "android", target_os = "fuchsia", target_os = "linux", target_os = "windows"))))'.dependencies]
spin = { version = "0.9.2", default-features = false, features = ["once"] }

[target.'cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))'.dependencies]
Expand Down
33 changes: 21 additions & 12 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,30 @@ pub(crate) struct Features(());

#[inline(always)]
pub(crate) fn features() -> Features {
// We don't do runtime feature detection on aarch64-apple-* as all AAarch64
// features we use are available on every device since the first devices.
// TODO: The list of operating systems for `aarch64` should really be
// "whatever has `std::arch::is_aarch64_feature_detected`".
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
all(
any(target_arch = "aarch64", target_arch = "arm"),
target_arch = "aarch64",
any(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "windows",
)
),
all(
target_arch = "arm",
any(
target_os = "android",
target_os = "fuchsia",
Expand All @@ -52,15 +69,7 @@ pub(crate) fn features() -> Features {
}
}

#[cfg(all(
any(target_arch = "aarch64", target_arch = "arm"),
any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux",
target_os = "windows"
)
))]
#[cfg(any(target_arch = "aarch64", target_arch = "arm"))]
{
arm::setup();
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! features {
};
)+

#[cfg(target_arch = "aarch64")]
#[cfg(all(target_arch = "aarch64", any(target_family = "unix", target_family = "windows")))]
pub fn setup() {
extern crate std;
use std::arch::is_aarch64_feature_detected;
Expand Down

0 comments on commit aa15beb

Please sign in to comment.