From 73af7aac8ddec209795ba1af57f79fb651837452 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sat, 20 Jul 2024 16:56:34 +0800 Subject: [PATCH] Add missing constant for Android (backport ) (cherry picked from commit 93e531e09522134923981bab39757479809f8cf4) --- libc-test/semver/android-aarch64.txt | 2 ++ libc-test/semver/android-arm.txt | 1 + libc-test/semver/android-i686.txt | 4 +++ libc-test/semver/android-x86_64.txt | 2 ++ libc-test/semver/android.txt | 26 +++++++++++++++++ src/unix/linux_like/android/b32/arm.rs | 3 ++ src/unix/linux_like/android/b32/x86/mod.rs | 5 ++++ .../linux_like/android/b64/aarch64/mod.rs | 3 ++ src/unix/linux_like/android/b64/mod.rs | 26 ----------------- .../linux_like/android/b64/riscv64/mod.rs | 12 ++++++++ src/unix/linux_like/android/b64/x86_64/mod.rs | 4 +++ src/unix/linux_like/android/mod.rs | 28 +++++++++++++++++++ 12 files changed, 90 insertions(+), 26 deletions(-) diff --git a/libc-test/semver/android-aarch64.txt b/libc-test/semver/android-aarch64.txt index 8a38e32dd5022..d634779743526 100644 --- a/libc-test/semver/android-aarch64.txt +++ b/libc-test/semver/android-aarch64.txt @@ -1,3 +1,5 @@ +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH HWCAP2_DCPODP HWCAP2_FLAGM2 HWCAP2_FRINT diff --git a/libc-test/semver/android-arm.txt b/libc-test/semver/android-arm.txt index fe1ce5bba1c5d..15578095c5c5f 100644 --- a/libc-test/semver/android-arm.txt +++ b/libc-test/semver/android-arm.txt @@ -1,3 +1,4 @@ +AT_SYSINFO_EHDR NGREG PTRACE_GETFPREGS PTRACE_GETREGS diff --git a/libc-test/semver/android-i686.txt b/libc-test/semver/android-i686.txt index eb6ecadba60b5..5ffb45ebc32c6 100644 --- a/libc-test/semver/android-i686.txt +++ b/libc-test/semver/android-i686.txt @@ -1,3 +1,7 @@ +AT_SYSINFO +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH +SYS_memfd_secret __c_anonymous_uc_sigmask __c_anonymous_uc_sigmask_with_padding time64_t diff --git a/libc-test/semver/android-x86_64.txt b/libc-test/semver/android-x86_64.txt index c4bb87bccb66d..05919bb6f40e5 100644 --- a/libc-test/semver/android-x86_64.txt +++ b/libc-test/semver/android-x86_64.txt @@ -1,3 +1,5 @@ +AT_SYSINFO_EHDR +AT_VECTOR_SIZE_ARCH EFLAGS FS_BASE GS_BASE diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 0bf7f422a2f49..0c95471985c0c 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -136,13 +136,39 @@ ATF_NETMASK ATF_PERM ATF_PUBL ATF_USETRAILERS +AT_BASE +AT_BASE_PLATFORM +AT_CLKTCK +AT_EGID AT_EMPTY_PATH +AT_ENTRY +AT_EUID +AT_EXECFD +AT_EXECFN AT_FDCWD +AT_FLAGS +AT_GID +AT_HWCAP +AT_HWCAP2 +AT_IGNORE +AT_MINSIGSTKSZ +AT_NOTELF AT_NO_AUTOMOUNT +AT_NULL +AT_PAGESZ +AT_PHDR +AT_PHENT +AT_PHNUM +AT_PLATFORM +AT_RANDOM AT_RECURSIVE AT_REMOVEDIR +AT_RSEQ_ALIGN +AT_RSEQ_FEATURE_SIZE +AT_SECURE AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW +AT_UID B0 B1000000 B110 diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index a062175eef746..c4c78939cba48 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -533,6 +533,9 @@ pub const REG_R15: ::c_int = 15; pub const NGREG: ::c_int = 18; +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: ::c_ulong = 33; + f! { // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not // exposed by the libc. As work-around, we implement it through `syscall` diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index e549f3b5168e6..64ce93dd22916 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -585,6 +585,11 @@ pub const REG_EFL: ::c_int = 16; pub const REG_UESP: ::c_int = 17; pub const REG_SS: ::c_int = 18; +// From NDK's asm/auxvec.h +pub const AT_SYSINFO: ::c_ulong = 32; +pub const AT_SYSINFO_EHDR: ::c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 3; + // socketcall values from linux/net.h (only the needed ones, and not public) const SYS_ACCEPT4: ::c_int = 18; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 7b87a1d49dc3e..37bbc612751d2 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -423,6 +423,9 @@ cfg_if! { pub use self::align::*; } } +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: ::c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2; cfg_if! { if #[cfg(libc_int128)] { diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 9639e1b4fa589..97cf137b7fc79 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -264,32 +264,6 @@ 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 AT_MINSIGSTKSZ: ::c_ulong = 51; - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, __reserved: [0; 36], diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 9d414dc15fb39..6724659f3ede4 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -351,3 +351,15 @@ cfg_if! { pub use self::align::*; } } + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: ::c_ulong = 33; +pub const AT_L1I_CACHESIZE: ::c_ulong = 40; +pub const AT_L1I_CACHEGEOMETRY: ::c_ulong = 41; +pub const AT_L1D_CACHESIZE: ::c_ulong = 42; +pub const AT_L1D_CACHEGEOMETRY: ::c_ulong = 43; +pub const AT_L2_CACHESIZE: ::c_ulong = 44; +pub const AT_L2_CACHEGEOMETRY: ::c_ulong = 45; +pub const AT_L3_CACHESIZE: ::c_ulong = 46; +pub const AT_L3_CACHEGEOMETRY: ::c_ulong = 47; +pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 9; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index be6b5011c21cc..e4bbf7b9ef186 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -800,3 +800,7 @@ cfg_if! { pub use self::align::*; } } + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: ::c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 3; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 535e874080633..3a326ab3923c4 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3523,6 +3523,34 @@ pub const PF_MEMALLOC_PIN: ::c_int = 0x10000000; pub const PF_SUSPEND_TASK: ::c_int = 0x80000000; +// 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_RSEQ_FEATURE_SIZE: ::c_ulong = 27; +pub const AT_RSEQ_ALIGN: ::c_ulong = 28; +pub const AT_EXECFN: ::c_ulong = 31; +pub const AT_MINSIGSTKSZ: ::c_ulong = 51; + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here.