Skip to content

Commit 9777567

Browse files
authored
Add support for AArch64 Android (essentially a Linux variant) (#752)
1 parent 7c931b8 commit 9777567

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cpufeatures/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ libc = "0.2.68"
1919

2020
[target.'cfg(all(target_arch = "aarch64", target_os = "linux"))'.dependencies]
2121
libc = "0.2.68"
22+
23+
[target.aarch64-linux-android.dependencies]
24+
libc = "0.2.68"

cpufeatures/src/aarch64.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! __unless_target_features {
2121
}
2222

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

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

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

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

@@ -167,7 +167,12 @@ macro_rules! check {
167167
}
168168

169169
// On other targets, runtime CPU feature detection is unavailable
170-
#[cfg(not(any(target_os = "ios", target_os = "linux", target_os = "macos")))]
170+
#[cfg(not(any(
171+
target_os = "ios",
172+
target_os = "linux",
173+
target_os = "android",
174+
target_os = "macos"
175+
)))]
171176
#[macro_export]
172177
#[doc(hidden)]
173178
macro_rules! __detect_target_features {

0 commit comments

Comments
 (0)