From bcfa360847b107942928b9f271cdfdceb781bf1a Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 29 Feb 2024 20:05:44 +0000 Subject: [PATCH] adding few android api 30 calls. close #3598. (backport ) (cherry picked from commit 7de90611bb9268b7f87444d39b5efc02b263efac) --- libc-test/build.rs | 2 +- libc-test/semver/android.txt | 5 ++ src/unix/linux_like/android/b32/mod.rs | 1 + .../linux_like/android/b64/aarch64/mod.rs | 1 + .../linux_like/android/b64/riscv64/mod.rs | 1 + src/unix/linux_like/android/b64/x86_64/mod.rs | 1 + src/unix/linux_like/android/mod.rs | 50 ++++++++++++++++++- 7 files changed, 59 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c4b344f41b028..6b3e6abb166c3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2075,7 +2075,7 @@ fn test_android(target: &str) { "__system_property_wait" => true, // Added in API level 30, but tests use level 28. - "mlock2" => true, + "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true, // Added in glibc 2.25. "getentropy" => true, diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 2c49d75c4466f..06a28efaac820 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3469,6 +3469,7 @@ memalign memchr memcmp memcpy +memfd_create memmem memmove memrchr @@ -3484,6 +3485,7 @@ mknodat mkstemp mktime mlock +mlock2 mlockall mmap mmap64 @@ -3672,6 +3674,7 @@ remove removexattr rename renameat +renameat2 res_init rewind rewinddir @@ -3797,6 +3800,8 @@ statfs statfs64 statvfs statvfs64 +statx +statx_timestamp strcasecmp strcasestr strcat diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 1f4f796f2a94a..aa29267f9db50 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -9,6 +9,7 @@ pub type sigset_t = ::c_ulong; pub type socklen_t = i32; pub type time64_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 0d6f32ee3989c..9587770e8cb2c 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type wchar_t = u32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 0251804691fd6..82a3aa62f51a5 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -2,6 +2,7 @@ pub type c_char = i8; pub type wchar_t = u32; pub type greg_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { 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 f871fb2cd4a61..57a41a224fe2c 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -2,6 +2,7 @@ pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 75f8a7877b617..3e30ce5bb17cf 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -514,8 +514,40 @@ s! { pub ifr6_addr: ::in6_addr, pub ifr6_prefixlen: u32, pub ifr6_ifindex: ::c_int, - } + } + + pub struct statx { + pub stx_mask: ::__u32, + pub stx_blksize: ::__u32, + pub stx_attributes: ::__u64, + pub stx_nlink: ::__u32, + pub stx_uid: ::__u32, + pub stx_gid: ::__u32, + pub stx_mode: ::__u16, + __statx_pad1: [::__u16; 1], + pub stx_ino: ::__u64, + pub stx_size: ::__u64, + pub stx_blocks: ::__u64, + pub stx_attributes_mask: ::__u64, + pub stx_atime: ::statx_timestamp, + pub stx_btime: ::statx_timestamp, + pub stx_ctime: ::statx_timestamp, + pub stx_mtime: ::statx_timestamp, + pub stx_rdev_major: ::__u32, + pub stx_rdev_minor: ::__u32, + pub stx_dev_major: ::__u32, + pub stx_dev_minor: ::__u32, + pub stx_mnt_id: ::__u64, + pub stx_dio_mem_align: ::__u32, + pub stx_dio_offset_align: ::__u32, + __statx_pad3: [::__u64; 12], + } + pub struct statx_timestamp { + pub tv_sec: ::__s64, + pub tv_nsec: ::__u32, + pub __reserved: ::__s32, + } } s_no_extra_traits! { @@ -4169,6 +4201,22 @@ extern "C" { pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char; pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn renameat2( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + flags: ::c_uint, + ) -> ::c_int; + pub fn statx( + dirfd: ::c_int, + pathname: *const c_char, + flags: ::c_int, + mask: ::c_uint, + statxbuf: *mut statx, + ) -> ::c_int; } cfg_if! {