Skip to content

Commit 4d0e2b3

Browse files
authored
Merge pull request #1795 from qwandor-google/master
2 parents cd6001c + 51acd7f commit 4d0e2b3

File tree

4 files changed

+148
-6
lines changed

4 files changed

+148
-6
lines changed

ci/android-install-ndk.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -ex
44

5-
NDK=android-ndk-r19c
5+
NDK=android-ndk-r21d
66
curl --retry 20 -O https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
77
unzip -q ${NDK}-linux-x86_64.zip
88

libc-test/build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,7 @@ fn test_android(target: &str) {
14271427
"sys/sysinfo.h",
14281428
"sys/time.h",
14291429
"sys/times.h",
1430+
"sys/timerfd.h",
14301431
"sys/types.h",
14311432
"sys/ucontext.h",
14321433
"sys/uio.h",
@@ -1454,6 +1455,7 @@ fn test_android(target: &str) {
14541455
"asm/mman.h",
14551456
"linux/dccp.h",
14561457
"linux/errqueue.h",
1458+
"linux/falloc.h",
14571459
"linux/futex.h",
14581460
"linux/fs.h",
14591461
"linux/genetlink.h",
@@ -1475,6 +1477,7 @@ fn test_android(target: &str) {
14751477
"linux/quota.h",
14761478
"linux/reboot.h",
14771479
"linux/seccomp.h",
1480+
"linux/sched.h",
14781481
"linux/sockios.h",
14791482

14801483
}
@@ -1577,7 +1580,7 @@ fn test_android(target: &str) {
15771580
// https://github.com/rust-lang/libc/issues/1765
15781581
"lockf" | "preadv64" | "pwritev64" | "openpty" | "forkpty"
15791582
| "login_tty" | "getifaddrs" | "freeifaddrs" | "sethostname"
1580-
| "getgrgid_r" | "getgrnam_r"
1583+
| "getgrgid_r" | "getgrnam_r" | "sigtimedwait"
15811584
if aarch64 =>
15821585
{
15831586
true

src/unix/linux_like/android/b64/aarch64/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub const SYS_pwritev2: ::c_long = 287;
322322
pub const SYS_pkey_mprotect: ::c_long = 288;
323323
pub const SYS_pkey_alloc: ::c_long = 289;
324324
pub const SYS_pkey_free: ::c_long = 290;
325-
pub const SYS_syscalls: ::c_long = 292;
325+
pub const SYS_syscalls: ::c_long = 436;
326326

327327
cfg_if! {
328328
if #[cfg(libc_align)] {

src/unix/linux_like/android/mod.rs

+142-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub type nfds_t = ::c_uint;
1919
pub type rlim_t = ::c_ulong;
2020
pub type dev_t = ::c_ulong;
2121
pub type ino_t = ::c_ulong;
22+
pub type ino64_t = u64;
2223
pub type __CPU_BITTYPE = ::c_ulong;
2324
pub type idtype_t = ::c_int;
2425
pub type loff_t = ::c_longlong;
@@ -147,6 +148,11 @@ s! {
147148
_pad: [u8; 28],
148149
}
149150

151+
pub struct itimerspec {
152+
pub it_interval: ::timespec,
153+
pub it_value: ::timespec,
154+
}
155+
150156
pub struct ucred {
151157
pub pid: ::pid_t,
152158
pub uid: ::uid_t,
@@ -629,11 +635,27 @@ pub const EPOLLONESHOT: ::c_int = 0x40000000;
629635
pub const EPOLLRDHUP: ::c_int = 0x00002000;
630636
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
631637

632-
pub const EFD_CLOEXEC: ::c_int = 0x80000;
638+
// sys/eventfd.h
639+
pub const EFD_SEMAPHORE: ::c_int = 0x1;
640+
pub const EFD_CLOEXEC: ::c_int = O_CLOEXEC;
641+
pub const EFD_NONBLOCK: ::c_int = O_NONBLOCK;
642+
643+
// sys/timerfd.h
644+
pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
645+
pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
646+
pub const TFD_TIMER_ABSTIME: ::c_int = 1;
647+
pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 2;
633648

634649
pub const USER_PROCESS: ::c_short = 7;
635650

651+
// linux/falloc.h
652+
pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
653+
pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
654+
pub const FALLOC_FL_NO_HIDE_STALE: ::c_int = 0x04;
636655
pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
656+
pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
657+
pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
658+
pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
637659

638660
pub const BUFSIZ: ::c_uint = 1024;
639661
pub const FILENAME_MAX: ::c_uint = 4096;
@@ -804,6 +826,11 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
804826
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
805827
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
806828

829+
// stdio.h
830+
pub const RENAME_NOREPLACE: ::c_int = 1;
831+
pub const RENAME_EXCHANGE: ::c_int = 2;
832+
pub const RENAME_WHITEOUT: ::c_int = 4;
833+
807834
pub const FIOCLEX: ::c_int = 0x5451;
808835
pub const FIONCLEX: ::c_int = 0x5450;
809836

@@ -1097,8 +1124,6 @@ pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
10971124
pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
10981125
pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
10991126

1100-
pub const EFD_NONBLOCK: ::c_int = 0x800;
1101-
11021127
pub const F_GETLK: ::c_int = 5;
11031128
pub const F_GETOWN: ::c_int = 9;
11041129
pub const F_SETOWN: ::c_int = 8;
@@ -2148,6 +2173,18 @@ pub const PRIO_PROCESS: ::c_int = 0;
21482173
pub const PRIO_PGRP: ::c_int = 1;
21492174
pub const PRIO_USER: ::c_int = 2;
21502175

2176+
// linux/sched.h
2177+
pub const SCHED_NORMAL: ::c_int = 0;
2178+
pub const SCHED_FIFO: ::c_int = 1;
2179+
pub const SCHED_RR: ::c_int = 2;
2180+
pub const SCHED_BATCH: ::c_int = 3;
2181+
pub const SCHED_IDLE: ::c_int = 5;
2182+
pub const SCHED_DEADLINE: ::c_int = 6;
2183+
2184+
// bits/seek_constants.h
2185+
pub const SEEK_DATA: ::c_int = 3;
2186+
pub const SEEK_HOLE: ::c_int = 4;
2187+
21512188
f! {
21522189
pub fn CMSG_NXTHDR(mhdr: *const msghdr,
21532190
cmsg: *const cmsghdr) -> *mut cmsghdr {
@@ -2218,6 +2255,18 @@ extern "C" {
22182255
pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
22192256
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
22202257
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
2258+
pub fn prlimit(
2259+
pid: ::pid_t,
2260+
resource: ::c_int,
2261+
new_limit: *const ::rlimit,
2262+
old_limit: *mut ::rlimit,
2263+
) -> ::c_int;
2264+
pub fn prlimit64(
2265+
pid: ::pid_t,
2266+
resource: ::c_int,
2267+
new_limit: *const ::rlimit64,
2268+
old_limit: *mut ::rlimit64,
2269+
) -> ::c_int;
22212270
pub fn strerror_r(
22222271
errnum: ::c_int,
22232272
buf: *mut c_char,
@@ -2273,16 +2322,101 @@ extern "C" {
22732322
pub fn setutent();
22742323
pub fn getutent() -> *mut utmp;
22752324

2325+
pub fn fallocate(
2326+
fd: ::c_int,
2327+
mode: ::c_int,
2328+
offset: ::off_t,
2329+
len: ::off_t,
2330+
) -> ::c_int;
2331+
pub fn fallocate64(
2332+
fd: ::c_int,
2333+
mode: ::c_int,
2334+
offset: ::off64_t,
2335+
len: ::off64_t,
2336+
) -> ::c_int;
22762337
pub fn posix_fallocate(
22772338
fd: ::c_int,
22782339
offset: ::off_t,
22792340
len: ::off_t,
22802341
) -> ::c_int;
2342+
pub fn posix_fallocate64(
2343+
fd: ::c_int,
2344+
offset: ::off64_t,
2345+
len: ::off64_t,
2346+
) -> ::c_int;
2347+
pub fn getxattr(
2348+
path: *const c_char,
2349+
name: *const c_char,
2350+
value: *mut ::c_void,
2351+
size: ::size_t,
2352+
) -> ::ssize_t;
2353+
pub fn lgetxattr(
2354+
path: *const c_char,
2355+
name: *const c_char,
2356+
value: *mut ::c_void,
2357+
size: ::size_t,
2358+
) -> ::ssize_t;
2359+
pub fn fgetxattr(
2360+
filedes: ::c_int,
2361+
name: *const c_char,
2362+
value: *mut ::c_void,
2363+
size: ::size_t,
2364+
) -> ::ssize_t;
2365+
pub fn setxattr(
2366+
path: *const c_char,
2367+
name: *const c_char,
2368+
value: *const ::c_void,
2369+
size: ::size_t,
2370+
flags: ::c_int,
2371+
) -> ::c_int;
2372+
pub fn lsetxattr(
2373+
path: *const c_char,
2374+
name: *const c_char,
2375+
value: *const ::c_void,
2376+
size: ::size_t,
2377+
flags: ::c_int,
2378+
) -> ::c_int;
2379+
pub fn fsetxattr(
2380+
filedes: ::c_int,
2381+
name: *const c_char,
2382+
value: *const ::c_void,
2383+
size: ::size_t,
2384+
flags: ::c_int,
2385+
) -> ::c_int;
2386+
pub fn listxattr(
2387+
path: *const c_char,
2388+
list: *mut c_char,
2389+
size: ::size_t,
2390+
) -> ::ssize_t;
2391+
pub fn llistxattr(
2392+
path: *const c_char,
2393+
list: *mut c_char,
2394+
size: ::size_t,
2395+
) -> ::ssize_t;
2396+
pub fn flistxattr(
2397+
filedes: ::c_int,
2398+
list: *mut c_char,
2399+
size: ::size_t,
2400+
) -> ::ssize_t;
2401+
pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
2402+
pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
2403+
pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
22812404
pub fn signalfd(
22822405
fd: ::c_int,
22832406
mask: *const ::sigset_t,
22842407
flags: ::c_int,
22852408
) -> ::c_int;
2409+
pub fn timerfd_create(clock: ::clockid_t, flags: ::c_int) -> ::c_int;
2410+
pub fn timerfd_gettime(
2411+
fd: ::c_int,
2412+
current_value: *mut itimerspec,
2413+
) -> ::c_int;
2414+
pub fn timerfd_settime(
2415+
fd: ::c_int,
2416+
flags: ::c_int,
2417+
new_value: *const itimerspec,
2418+
old_value: *mut itimerspec,
2419+
) -> ::c_int;
22862420
pub fn syscall(num: ::c_long, ...) -> ::c_long;
22872421
pub fn sched_getaffinity(
22882422
pid: ::pid_t,
@@ -2460,6 +2594,11 @@ extern "C" {
24602594
buflen: ::size_t,
24612595
result: *mut *mut passwd,
24622596
) -> ::c_int;
2597+
pub fn sigtimedwait(
2598+
set: *const sigset_t,
2599+
info: *mut siginfo_t,
2600+
timeout: *const ::timespec,
2601+
) -> ::c_int;
24632602
pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
24642603
pub fn pthread_atfork(
24652604
prepare: ::Option<unsafe extern "C" fn()>,

0 commit comments

Comments
 (0)