Skip to content

Add getauxval for 64-bit Android #1991

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
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: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ fn test_android(target: &str) {
"stdio.h",
"stdlib.h",
"string.h",
"sys/auxv.h",
"sys/epoll.h",
"sys/eventfd.h",
"sys/file.h",
Expand Down Expand Up @@ -1472,6 +1473,7 @@ fn test_android(target: &str) {
// Include linux headers at the end:
headers! { cfg:
"asm/mman.h",
"linux/auxvec.h",
"linux/dccp.h",
"linux/errqueue.h",
"linux/falloc.h",
Expand Down
43 changes: 43 additions & 0 deletions src/unix/linux_like/android/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,49 @@ pub const O_LARGEFILE: ::c_int = 0o400000;
pub const SIGSTKSZ: ::size_t = 16384;
pub const MINSIGSTKSZ: ::size_t = 5120;

// From NDK's asm/hwcap.h
pub const HWCAP_FP: ::c_ulong = 1 << 0;
pub const HWCAP_ASIMD: ::c_ulong = 1 << 1;
pub const HWCAP_EVTSTRM: ::c_ulong = 1 << 2;
pub const HWCAP_AES: ::c_ulong = 1 << 3;
pub const HWCAP_PMULL: ::c_ulong = 1 << 4;
pub const HWCAP_SHA1: ::c_ulong = 1 << 5;
pub const HWCAP_SHA2: ::c_ulong = 1 << 6;
pub const HWCAP_CRC32: ::c_ulong = 1 << 7;
pub const HWCAP_ATOMICS: ::c_ulong = 1 << 8;
pub const HWCAP_FPHP: ::c_ulong = 1 << 9;
pub const HWCAP_ASIMDHP: ::c_ulong = 1 << 10;
pub const HWCAP_CPUID: ::c_ulong = 1 << 11;
pub const HWCAP_ASIMDRDM: ::c_ulong = 1 << 12;
pub const HWCAP_JSCVT: ::c_ulong = 1 << 13;
pub const HWCAP_FCMA: ::c_ulong = 1 << 14;
pub const HWCAP_LRCPC: ::c_ulong = 1 << 15;
pub const HWCAP_DCPOP: ::c_ulong = 1 << 16;
pub const HWCAP_SHA3: ::c_ulong = 1 << 17;
pub const HWCAP_SM3: ::c_ulong = 1 << 18;
pub const HWCAP_SM4: ::c_ulong = 1 << 19;
pub const HWCAP_ASIMDDP: ::c_ulong = 1 << 20;
pub const HWCAP_SHA512: ::c_ulong = 1 << 21;
pub const HWCAP_SVE: ::c_ulong = 1 << 22;
pub const HWCAP_ASIMDFHM: ::c_ulong = 1 << 23;
pub const HWCAP_DIT: ::c_ulong = 1 << 24;
pub const HWCAP_USCAT: ::c_ulong = 1 << 25;
pub const HWCAP_ILRCPC: ::c_ulong = 1 << 26;
pub const HWCAP_FLAGM: ::c_ulong = 1 << 27;
pub const HWCAP_SSBS: ::c_ulong = 1 << 28;
pub const HWCAP_SB: ::c_ulong = 1 << 29;
pub const HWCAP_PACA: ::c_ulong = 1 << 30;
pub const HWCAP_PACG: ::c_ulong = 1 << 31;
pub const HWCAP2_DCPODP: ::c_ulong = 1 << 0;
pub const HWCAP2_SVE2: ::c_ulong = 1 << 1;
pub const HWCAP2_SVEAES: ::c_ulong = 1 << 2;
pub const HWCAP2_SVEPMULL: ::c_ulong = 1 << 3;
pub const HWCAP2_SVEBITPERM: ::c_ulong = 1 << 4;
pub const HWCAP2_SVESHA3: ::c_ulong = 1 << 5;
pub const HWCAP2_SVESM4: ::c_ulong = 1 << 6;
pub const HWCAP2_FLAGM2: ::c_ulong = 1 << 7;
pub const HWCAP2_FRINT: ::c_ulong = 1 << 8;

pub const SYS_io_setup: ::c_long = 0;
pub const SYS_io_destroy: ::c_long = 1;
pub const SYS_io_submit: ::c_long = 2;
Expand Down
29 changes: 29 additions & 0 deletions src/unix/linux_like/android/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ pub const RTLD_GLOBAL: ::c_int = 0x00100;
pub const RTLD_NOW: ::c_int = 2;
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;

// From NDK's linux/auxvec.h
pub const AT_NULL: ::c_ulong = 0;
pub const AT_IGNORE: ::c_ulong = 1;
pub const AT_EXECFD: ::c_ulong = 2;
pub const AT_PHDR: ::c_ulong = 3;
pub const AT_PHENT: ::c_ulong = 4;
pub const AT_PHNUM: ::c_ulong = 5;
pub const AT_PAGESZ: ::c_ulong = 6;
pub const AT_BASE: ::c_ulong = 7;
pub const AT_FLAGS: ::c_ulong = 8;
pub const AT_ENTRY: ::c_ulong = 9;
pub const AT_NOTELF: ::c_ulong = 10;
pub const AT_UID: ::c_ulong = 11;
pub const AT_EUID: ::c_ulong = 12;
pub const AT_GID: ::c_ulong = 13;
pub const AT_EGID: ::c_ulong = 14;
pub const AT_PLATFORM: ::c_ulong = 15;
pub const AT_HWCAP: ::c_ulong = 16;
pub const AT_CLKTCK: ::c_ulong = 17;
pub const AT_SECURE: ::c_ulong = 23;
pub const AT_BASE_PLATFORM: ::c_ulong = 24;
pub const AT_RANDOM: ::c_ulong = 25;
pub const AT_HWCAP2: ::c_ulong = 26;
pub const AT_EXECFN: ::c_ulong = 31;

pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
value: 0,
__reserved: [0; 36],
Expand All @@ -280,6 +305,10 @@ pub const UT_LINESIZE: usize = 32;
pub const UT_NAMESIZE: usize = 32;
pub const UT_HOSTSIZE: usize = 256;

extern "C" {
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
}

cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
Expand Down