Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu.rs: Clarify conditions under which runtime CPU feature detection is done. #1099

Merged
merged 1 commit into from
Nov 18, 2020
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ name = "ring"
[dependencies]
untrusted = { version = "0.7.1" }

[target.'cfg(all(any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86", target_arch = "x86_64"), not(target_os = "ios")))'.dependencies]
[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"))))'.dependencies]
spin = { version = "0.5.2", default-features = false }

[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
Expand Down
41 changes: 18 additions & 23 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ pub(crate) struct Features(());

#[inline(always)]
pub(crate) fn features() -> Features {
// We don't do runtime feature detection on iOS. instead some features are
// assumed to be present; see `arm::Feature`.
#[cfg(all(
any(
target_arch = "aarch64",
target_arch = "arm",
target_arch = "x86",
target_arch = "x86_64"
),
not(target_os = "ios")
// We don't do runtime feature detection on aarch64-apple-ios as all
// AAarch64 features we use are available on every device since the first
// device.
#[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")
)
))]
{
static INIT: spin::Once<()> = spin::Once::new();
Expand All @@ -49,16 +49,11 @@ pub(crate) fn features() -> Features {
}

#[cfg(all(
any(target_os = "android", target_os = "linux"),
any(target_arch = "aarch64", target_arch = "arm")
any(target_arch = "aarch64", target_arch = "arm"),
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
))]
{
arm::linux_setup();
}

#[cfg(all(target_os = "fuchsia", any(target_arch = "aarch64")))]
{
arm::fuchsia_setup();
arm::setup();
}
});
}
Expand All @@ -71,7 +66,7 @@ pub(crate) mod arm {
any(target_os = "android", target_os = "linux"),
any(target_arch = "aarch64", target_arch = "arm")
))]
pub fn linux_setup() {
pub fn setup() {
use libc::c_ulong;

// XXX: The `libc` crate doesn't provide `libc::getauxval` consistently
Expand Down Expand Up @@ -130,8 +125,8 @@ pub(crate) mod arm {
}
}

#[cfg(all(target_os = "fuchsia", any(target_arch = "aarch64")))]
pub fn fuchsia_setup() {
#[cfg(all(target_os = "fuchsia", target_arch = "aarch64"))]
pub fn setup() {
type zx_status_t = i32;

#[link(name = "zircon")]
Expand Down Expand Up @@ -194,7 +189,7 @@ pub(crate) mod arm {
}

#[cfg(all(
any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
any(target_os = "android", target_os = "fuchsia", target_os = "linux"),
any(target_arch = "arm", target_arch = "aarch64")
))]
{
Expand Down Expand Up @@ -243,7 +238,7 @@ pub(crate) mod arm {
};

#[cfg(all(
any(target_os = "android", target_os = "linux", target_os = "fuchsia"),
any(target_os = "android", target_os = "fuchsia", target_os = "linux"),
any(target_arch = "arm", target_arch = "aarch64")
))]
extern "C" {
Expand Down