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
3 changes: 3 additions & 0 deletions cpufeatures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ libc = "0.2.68"

[target.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.dependencies]
libc = "0.2.68"

[target.aarch64-linux-android.dependencies]
libc = "0.2.68"
Comment thread
tarcieri marked this conversation as resolved.
17 changes: 11 additions & 6 deletions cpufeatures/src/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! __unless_target_features {
}

// Linux runtime detection of target CPU features using `getauxval`.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[macro_export]
#[doc(hidden)]
macro_rules! __detect_target_features {
Expand All @@ -32,7 +32,7 @@ macro_rules! __detect_target_features {
}

/// Linux helper function for calling `getauxval` to get `AT_HWCAP`.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub fn getauxval_hwcap() -> u64 {
unsafe { libc::getauxval(libc::AT_HWCAP) }
}
Expand All @@ -48,7 +48,7 @@ macro_rules! __detect_target_features {
}

// Linux `expand_check_macro`
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
macro_rules! __expand_check_macro {
($(($name:tt, $hwcap:ident)),* $(,)?) => {
#[macro_export]
Expand All @@ -64,7 +64,7 @@ macro_rules! __expand_check_macro {
}

// Linux `expand_check_macro`
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
__expand_check_macro! {
("aes", AES), // Enable AES support.
("sha2", SHA2), // Enable SHA1 and SHA256 support.
Expand All @@ -78,7 +78,7 @@ __expand_check_macro! {
/// provide that mapping accordingly.
///
/// See this issue for more info: <https://github.com/RustCrypto/utils/issues/395>
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod hwcaps {
use libc::c_ulong;

Expand Down Expand Up @@ -167,7 +167,12 @@ macro_rules! check {
}

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