Skip to content

cpufeatures: add iOS support (static ARM64 capabilities only) #435

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

Merged
merged 1 commit into from
May 26, 2021
Merged
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
25 changes: 24 additions & 1 deletion cpufeatures/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,31 @@ pub unsafe fn sysctlbyname(name: &[u8]) -> bool {
value != 0
}

// iOS `check!` macro.
//
// Unfortunately iOS does not provide access to the `sysctl(3)` API which means
// we can only return static values for CPU features which can be assumed to
// be present on all Apple ARM64 hardware.
//
// See discussion on this issue for more information:
// <https://github.com/RustCrypto/utils/issues/378>
#[cfg(target_os = "ios")]
#[macro_export]
#[doc(hidden)]
macro_rules! check {
("aes") => {
true
};
("sha2") => {
true
};
("sha3") => {
false
};
}

// On other targets, runtime CPU feature detection is unavailable
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(target_os = "ios", target_os = "linux", target_os = "macos")))]
#[macro_export]
#[doc(hidden)]
macro_rules! __detect_target_features {
Expand Down