Skip to content

Commit

Permalink
adding few android api 30 calls.
Browse files Browse the repository at this point in the history
close rust-lang#3598.

(backport <rust-lang#3604>)
(cherry picked from commit 7de9061)
  • Loading branch information
devnexen authored and tgross35 committed Nov 18, 2024
1 parent 70e2542 commit bcfa360
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3469,6 +3469,7 @@ memalign
memchr
memcmp
memcpy
memfd_create
memmem
memmove
memrchr
Expand All @@ -3484,6 +3485,7 @@ mknodat
mkstemp
mktime
mlock
mlock2
mlockall
mmap
mmap64
Expand Down Expand Up @@ -3672,6 +3674,7 @@ remove
removexattr
rename
renameat
renameat2
res_init
rewind
rewinddir
Expand Down Expand Up @@ -3797,6 +3800,8 @@ statfs
statfs64
statvfs
statvfs64
statx
statx_timestamp
strcasecmp
strcasestr
strcat
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/android/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
50 changes: 49 additions & 1 deletion src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down Expand Up @@ -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! {
Expand Down

0 comments on commit bcfa360

Please sign in to comment.