Skip to content

Commit

Permalink
Merge pull request #3779 from yujincheng08/main
Browse files Browse the repository at this point in the history
Add missing constants for Android
  • Loading branch information
tgross35 authored Aug 16, 2024
2 parents bc3c8cb + 1610dd3 commit 8583c71
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -ex

NDK=android-ndk-r26b
NDK=android-ndk-r27
wget --tries=20 -q https://dl.google.com/android/repository/${NDK}-linux.zip
unzip -q ${NDK}-linux.zip

Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/android-aarch64.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AT_SYSINFO_EHDR
AT_VECTOR_SIZE_ARCH
HWCAP2_DCPODP
HWCAP2_FLAGM2
HWCAP2_FRINT
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/android-arm.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AT_SYSINFO_EHDR
NGREG
PTRACE_GETFPREGS
PTRACE_GETREGS
Expand Down
3 changes: 3 additions & 0 deletions libc-test/semver/android-i686.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AT_SYSINFO
AT_SYSINFO_EHDR
AT_VECTOR_SIZE_ARCH
SYS_memfd_secret
__c_anonymous_uc_sigmask
__c_anonymous_uc_sigmask_with_padding
Expand Down
90 changes: 90 additions & 0 deletions libc-test/semver/android-riscv64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
AT_SYSINFO_EHDR
AT_VECTOR_SIZE_ARCH
HWCAP2_AFP
HWCAP2_BF16
HWCAP2_BTI
HWCAP2_DCPODP
HWCAP2_DGH
HWCAP2_EBF16
HWCAP2_ECV
HWCAP2_FLAGM2
HWCAP2_FRINT
HWCAP2_I8MM
HWCAP2_MTE
HWCAP2_MTE3
HWCAP2_RNG
HWCAP2_RPRES
HWCAP2_SME
HWCAP2_SME_B16F32
HWCAP2_SME_F16F32
HWCAP2_SME_F32F32
HWCAP2_SME_F64F64
HWCAP2_SME_FA64
HWCAP2_SME_I16I64
HWCAP2_SME_I8I32
HWCAP2_SVE2
HWCAP2_SVEAES
HWCAP2_SVEBF16
HWCAP2_SVEBITPERM
HWCAP2_SVEF32MM
HWCAP2_SVEF64MM
HWCAP2_SVEI8MM
HWCAP2_SVEPMULL
HWCAP2_SVESHA3
HWCAP2_SVESM4
HWCAP2_SVE_EBF16
HWCAP2_WFXT
HWCAP_AES
HWCAP_ASIMD
HWCAP_ASIMDDP
HWCAP_ASIMDFHM
HWCAP_ASIMDHP
HWCAP_ASIMDRDM
HWCAP_ATOMICS
HWCAP_CPUID
HWCAP_CRC32
HWCAP_DCPOP
HWCAP_DIT
HWCAP_EVTSTRM
HWCAP_FCMA
HWCAP_FLAGM
HWCAP_FP
HWCAP_FPHP
HWCAP_ILRCPC
HWCAP_JSCVT
HWCAP_LRCPC
HWCAP_PACA
HWCAP_PACG
HWCAP_PMULL
HWCAP_SB
HWCAP_SHA1
HWCAP_SHA2
HWCAP_SHA3
HWCAP_SHA512
HWCAP_SM3
HWCAP_SM4
HWCAP_SSBS
HWCAP_SVE
HWCAP_USCAT
PROT_BTI
PROT_MTE
SYS_accept
SYS_arch_specific_syscall
SYS_fcntl
SYS_getrlimit
SYS_memfd_secret
SYS_migrate_pages
SYS_msgctl
SYS_msgget
SYS_msgrcv
SYS_msgsnd
SYS_semctl
SYS_semget
SYS_semop
SYS_semtimedop
SYS_shmat
SYS_shmctl
SYS_shmdt
SYS_shmget
SYS_sync_file_range
SYS_syscalls
2 changes: 2 additions & 0 deletions libc-test/semver/android-x86_64.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AT_SYSINFO_EHDR
AT_VECTOR_SIZE_ARCH
EFLAGS
FS_BASE
GS_BASE
Expand Down
26 changes: 26 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/unix/linux_like/android/b32/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,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`
Expand Down
5 changes: 5 additions & 0 deletions src/unix/linux_like/android/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,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;

Expand Down
4 changes: 4 additions & 0 deletions src/unix/linux_like/android/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ pub const SYS_syscalls: ::c_long = 451;
pub const PROT_BTI: ::c_int = 0x10;
pub const PROT_MTE: ::c_int = 0x20;

// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: ::c_ulong = 33;
pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 2;

mod align;
pub use self::align::*;

Expand Down
26 changes: 0 additions & 26 deletions src/unix/linux_like/android/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
12 changes: 12 additions & 0 deletions src/unix/linux_like/android/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,17 @@ pub const SYS_process_mrelease: ::c_long = 448;
pub const SYS_futex_waitv: ::c_long = 449;
pub const SYS_set_mempolicy_home_node: ::c_long = 450;

// 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;

mod align;
pub use self::align::*;
4 changes: 4 additions & 0 deletions src/unix/linux_like/android/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,5 +808,9 @@ pub const REG_TRAPNO: ::c_int = 20;
pub const REG_OLDMASK: ::c_int = 21;
pub const REG_CR2: ::c_int = 22;

// From NDK's asm/auxvec.h
pub const AT_SYSINFO_EHDR: ::c_ulong = 33;
pub const AT_VECTOR_SIZE_ARCH: ::c_ulong = 3;

mod align;
pub use self::align::*;
28 changes: 28 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3520,6 +3520,34 @@ pub const KLOG_CONSOLE_LEVEL: ::c_int = 8;
pub const KLOG_SIZE_UNREAD: ::c_int = 9;
pub const KLOG_SIZE_BUFFER: ::c_int = 10;

// 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.
Expand Down

0 comments on commit 8583c71

Please sign in to comment.