Skip to content

Commit 71daf0c

Browse files
committed
Auto merge of #1991 - jack-signal:jack/add-getauxval-for-64-bit-android, r=JohnTitor
Add getauxval for 64-bit Android Fixes #1987 This adds `getauxval` declaration on all 64-bit Android targets. This function was not declared in Bionic until API level 18. 64-bit support was added to Android in 5.0 (API level 21) thus all 64-bit targets (including AFAICT MIPS64 though I am not able to confirm this) should have `getauxval` declared. The `AT_` constants should be the same on all platforms.
2 parents 70962e3 + 71bfcb8 commit 71daf0c

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ fn test_android(target: &str) {
14221422
"stdio.h",
14231423
"stdlib.h",
14241424
"string.h",
1425+
"sys/auxv.h",
14251426
"sys/epoll.h",
14261427
"sys/eventfd.h",
14271428
"sys/file.h",
@@ -1472,6 +1473,7 @@ fn test_android(target: &str) {
14721473
// Include linux headers at the end:
14731474
headers! { cfg:
14741475
"asm/mman.h",
1476+
"linux/auxvec.h",
14751477
"linux/dccp.h",
14761478
"linux/errqueue.h",
14771479
"linux/falloc.h",

src/unix/linux_like/android/b64/aarch64/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,49 @@ pub const O_LARGEFILE: ::c_int = 0o400000;
5757
pub const SIGSTKSZ: ::size_t = 16384;
5858
pub const MINSIGSTKSZ: ::size_t = 5120;
5959

60+
// From NDK's asm/hwcap.h
61+
pub const HWCAP_FP: ::c_ulong = 1 << 0;
62+
pub const HWCAP_ASIMD: ::c_ulong = 1 << 1;
63+
pub const HWCAP_EVTSTRM: ::c_ulong = 1 << 2;
64+
pub const HWCAP_AES: ::c_ulong = 1 << 3;
65+
pub const HWCAP_PMULL: ::c_ulong = 1 << 4;
66+
pub const HWCAP_SHA1: ::c_ulong = 1 << 5;
67+
pub const HWCAP_SHA2: ::c_ulong = 1 << 6;
68+
pub const HWCAP_CRC32: ::c_ulong = 1 << 7;
69+
pub const HWCAP_ATOMICS: ::c_ulong = 1 << 8;
70+
pub const HWCAP_FPHP: ::c_ulong = 1 << 9;
71+
pub const HWCAP_ASIMDHP: ::c_ulong = 1 << 10;
72+
pub const HWCAP_CPUID: ::c_ulong = 1 << 11;
73+
pub const HWCAP_ASIMDRDM: ::c_ulong = 1 << 12;
74+
pub const HWCAP_JSCVT: ::c_ulong = 1 << 13;
75+
pub const HWCAP_FCMA: ::c_ulong = 1 << 14;
76+
pub const HWCAP_LRCPC: ::c_ulong = 1 << 15;
77+
pub const HWCAP_DCPOP: ::c_ulong = 1 << 16;
78+
pub const HWCAP_SHA3: ::c_ulong = 1 << 17;
79+
pub const HWCAP_SM3: ::c_ulong = 1 << 18;
80+
pub const HWCAP_SM4: ::c_ulong = 1 << 19;
81+
pub const HWCAP_ASIMDDP: ::c_ulong = 1 << 20;
82+
pub const HWCAP_SHA512: ::c_ulong = 1 << 21;
83+
pub const HWCAP_SVE: ::c_ulong = 1 << 22;
84+
pub const HWCAP_ASIMDFHM: ::c_ulong = 1 << 23;
85+
pub const HWCAP_DIT: ::c_ulong = 1 << 24;
86+
pub const HWCAP_USCAT: ::c_ulong = 1 << 25;
87+
pub const HWCAP_ILRCPC: ::c_ulong = 1 << 26;
88+
pub const HWCAP_FLAGM: ::c_ulong = 1 << 27;
89+
pub const HWCAP_SSBS: ::c_ulong = 1 << 28;
90+
pub const HWCAP_SB: ::c_ulong = 1 << 29;
91+
pub const HWCAP_PACA: ::c_ulong = 1 << 30;
92+
pub const HWCAP_PACG: ::c_ulong = 1 << 31;
93+
pub const HWCAP2_DCPODP: ::c_ulong = 1 << 0;
94+
pub const HWCAP2_SVE2: ::c_ulong = 1 << 1;
95+
pub const HWCAP2_SVEAES: ::c_ulong = 1 << 2;
96+
pub const HWCAP2_SVEPMULL: ::c_ulong = 1 << 3;
97+
pub const HWCAP2_SVEBITPERM: ::c_ulong = 1 << 4;
98+
pub const HWCAP2_SVESHA3: ::c_ulong = 1 << 5;
99+
pub const HWCAP2_SVESM4: ::c_ulong = 1 << 6;
100+
pub const HWCAP2_FLAGM2: ::c_ulong = 1 << 7;
101+
pub const HWCAP2_FRINT: ::c_ulong = 1 << 8;
102+
60103
pub const SYS_io_setup: ::c_long = 0;
61104
pub const SYS_io_destroy: ::c_long = 1;
62105
pub const SYS_io_submit: ::c_long = 2;

src/unix/linux_like/android/b64/mod.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,31 @@ pub const RTLD_GLOBAL: ::c_int = 0x00100;
256256
pub const RTLD_NOW: ::c_int = 2;
257257
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
258258

259+
// From NDK's linux/auxvec.h
260+
pub const AT_NULL: ::c_ulong = 0;
261+
pub const AT_IGNORE: ::c_ulong = 1;
262+
pub const AT_EXECFD: ::c_ulong = 2;
263+
pub const AT_PHDR: ::c_ulong = 3;
264+
pub const AT_PHENT: ::c_ulong = 4;
265+
pub const AT_PHNUM: ::c_ulong = 5;
266+
pub const AT_PAGESZ: ::c_ulong = 6;
267+
pub const AT_BASE: ::c_ulong = 7;
268+
pub const AT_FLAGS: ::c_ulong = 8;
269+
pub const AT_ENTRY: ::c_ulong = 9;
270+
pub const AT_NOTELF: ::c_ulong = 10;
271+
pub const AT_UID: ::c_ulong = 11;
272+
pub const AT_EUID: ::c_ulong = 12;
273+
pub const AT_GID: ::c_ulong = 13;
274+
pub const AT_EGID: ::c_ulong = 14;
275+
pub const AT_PLATFORM: ::c_ulong = 15;
276+
pub const AT_HWCAP: ::c_ulong = 16;
277+
pub const AT_CLKTCK: ::c_ulong = 17;
278+
pub const AT_SECURE: ::c_ulong = 23;
279+
pub const AT_BASE_PLATFORM: ::c_ulong = 24;
280+
pub const AT_RANDOM: ::c_ulong = 25;
281+
pub const AT_HWCAP2: ::c_ulong = 26;
282+
pub const AT_EXECFN: ::c_ulong = 31;
283+
259284
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
260285
value: 0,
261286
__reserved: [0; 36],
@@ -280,6 +305,10 @@ pub const UT_LINESIZE: usize = 32;
280305
pub const UT_NAMESIZE: usize = 32;
281306
pub const UT_HOSTSIZE: usize = 256;
282307

308+
extern "C" {
309+
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
310+
}
311+
283312
cfg_if! {
284313
if #[cfg(target_arch = "x86_64")] {
285314
mod x86_64;

0 commit comments

Comments
 (0)