Android: Add various constants and functions.

In particular:
Add timerfd constants and functions, from sys/timerfd.h.
Add EFD_SEMAPHORE and group all EFD_ constants together.
Add sigtimedwait function, from signal.h.
Add missing fallocate constants and functions, from linux/falloc.h and fcntl.h.
Add xattr functions, from sys/xattr.h.
Add SCHED_ and SEEK_ constants, from linux/sched.h and bits/seek_constants.h.
Add rlimit functions, from sys/resource.h.
Add RENAME_ constants, from stdio.h.
Add ino64_t type, from sys/types.h.
This commit is contained in:
Andrew Walbran 2020-06-24 18:41:07 +01:00
parent 5f0466501c
commit 51acd7f488
2 changed files with 146 additions and 4 deletions

View File

@ -1427,6 +1427,7 @@ fn test_android(target: &str) {
"sys/sysinfo.h",
"sys/time.h",
"sys/times.h",
"sys/timerfd.h",
"sys/types.h",
"sys/ucontext.h",
"sys/uio.h",
@ -1454,6 +1455,7 @@ fn test_android(target: &str) {
"asm/mman.h",
"linux/dccp.h",
"linux/errqueue.h",
"linux/falloc.h",
"linux/futex.h",
"linux/fs.h",
"linux/genetlink.h",
@ -1475,6 +1477,7 @@ fn test_android(target: &str) {
"linux/quota.h",
"linux/reboot.h",
"linux/seccomp.h",
"linux/sched.h",
"linux/sockios.h",
}
@ -1577,7 +1580,7 @@ fn test_android(target: &str) {
// https://github.com/rust-lang/libc/issues/1765
"lockf" | "preadv64" | "pwritev64" | "openpty" | "forkpty"
| "login_tty" | "getifaddrs" | "freeifaddrs" | "sethostname"
| "getgrgid_r" | "getgrnam_r"
| "getgrgid_r" | "getgrnam_r" | "sigtimedwait"
if aarch64 =>
{
true

View File

@ -19,6 +19,7 @@ pub type nfds_t = ::c_uint;
pub type rlim_t = ::c_ulong;
pub type dev_t = ::c_ulong;
pub type ino_t = ::c_ulong;
pub type ino64_t = u64;
pub type __CPU_BITTYPE = ::c_ulong;
pub type idtype_t = ::c_int;
pub type loff_t = ::c_longlong;
@ -147,6 +148,11 @@ s! {
_pad: [u8; 28],
}
pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
@ -629,11 +635,27 @@ pub const EPOLLONESHOT: ::c_int = 0x40000000;
pub const EPOLLRDHUP: ::c_int = 0x00002000;
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
pub const EFD_CLOEXEC: ::c_int = 0x80000;
// sys/eventfd.h
pub const EFD_SEMAPHORE: ::c_int = 0x1;
pub const EFD_CLOEXEC: ::c_int = O_CLOEXEC;
pub const EFD_NONBLOCK: ::c_int = O_NONBLOCK;
// sys/timerfd.h
pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
pub const TFD_TIMER_ABSTIME: ::c_int = 1;
pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 2;
pub const USER_PROCESS: ::c_short = 7;
// linux/falloc.h
pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
pub const FALLOC_FL_NO_HIDE_STALE: ::c_int = 0x04;
pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
pub const BUFSIZ: ::c_uint = 1024;
pub const FILENAME_MAX: ::c_uint = 4096;
@ -804,6 +826,11 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
// stdio.h
pub const RENAME_NOREPLACE: ::c_int = 1;
pub const RENAME_EXCHANGE: ::c_int = 2;
pub const RENAME_WHITEOUT: ::c_int = 4;
pub const FIOCLEX: ::c_int = 0x5451;
pub const FIONCLEX: ::c_int = 0x5450;
@ -1097,8 +1124,6 @@ pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
pub const EFD_NONBLOCK: ::c_int = 0x800;
pub const F_GETLK: ::c_int = 5;
pub const F_GETOWN: ::c_int = 9;
pub const F_SETOWN: ::c_int = 8;
@ -2148,6 +2173,18 @@ pub const PRIO_PROCESS: ::c_int = 0;
pub const PRIO_PGRP: ::c_int = 1;
pub const PRIO_USER: ::c_int = 2;
// linux/sched.h
pub const SCHED_NORMAL: ::c_int = 0;
pub const SCHED_FIFO: ::c_int = 1;
pub const SCHED_RR: ::c_int = 2;
pub const SCHED_BATCH: ::c_int = 3;
pub const SCHED_IDLE: ::c_int = 5;
pub const SCHED_DEADLINE: ::c_int = 6;
// bits/seek_constants.h
pub const SEEK_DATA: ::c_int = 3;
pub const SEEK_HOLE: ::c_int = 4;
f! {
pub fn CMSG_NXTHDR(mhdr: *const msghdr,
cmsg: *const cmsghdr) -> *mut cmsghdr {
@ -2218,6 +2255,18 @@ extern "C" {
pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
pub fn prlimit(
pid: ::pid_t,
resource: ::c_int,
new_limit: *const ::rlimit,
old_limit: *mut ::rlimit,
) -> ::c_int;
pub fn prlimit64(
pid: ::pid_t,
resource: ::c_int,
new_limit: *const ::rlimit64,
old_limit: *mut ::rlimit64,
) -> ::c_int;
pub fn strerror_r(
errnum: ::c_int,
buf: *mut c_char,
@ -2273,16 +2322,101 @@ extern "C" {
pub fn setutent();
pub fn getutent() -> *mut utmp;
pub fn fallocate(
fd: ::c_int,
mode: ::c_int,
offset: ::off_t,
len: ::off_t,
) -> ::c_int;
pub fn fallocate64(
fd: ::c_int,
mode: ::c_int,
offset: ::off64_t,
len: ::off64_t,
) -> ::c_int;
pub fn posix_fallocate(
fd: ::c_int,
offset: ::off_t,
len: ::off_t,
) -> ::c_int;
pub fn posix_fallocate64(
fd: ::c_int,
offset: ::off64_t,
len: ::off64_t,
) -> ::c_int;
pub fn getxattr(
path: *const c_char,
name: *const c_char,
value: *mut ::c_void,
size: ::size_t,
) -> ::ssize_t;
pub fn lgetxattr(
path: *const c_char,
name: *const c_char,
value: *mut ::c_void,
size: ::size_t,
) -> ::ssize_t;
pub fn fgetxattr(
filedes: ::c_int,
name: *const c_char,
value: *mut ::c_void,
size: ::size_t,
) -> ::ssize_t;
pub fn setxattr(
path: *const c_char,
name: *const c_char,
value: *const ::c_void,
size: ::size_t,
flags: ::c_int,
) -> ::c_int;
pub fn lsetxattr(
path: *const c_char,
name: *const c_char,
value: *const ::c_void,
size: ::size_t,
flags: ::c_int,
) -> ::c_int;
pub fn fsetxattr(
filedes: ::c_int,
name: *const c_char,
value: *const ::c_void,
size: ::size_t,
flags: ::c_int,
) -> ::c_int;
pub fn listxattr(
path: *const c_char,
list: *mut c_char,
size: ::size_t,
) -> ::ssize_t;
pub fn llistxattr(
path: *const c_char,
list: *mut c_char,
size: ::size_t,
) -> ::ssize_t;
pub fn flistxattr(
filedes: ::c_int,
list: *mut c_char,
size: ::size_t,
) -> ::ssize_t;
pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int;
pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int;
pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int;
pub fn signalfd(
fd: ::c_int,
mask: *const ::sigset_t,
flags: ::c_int,
) -> ::c_int;
pub fn timerfd_create(clock: ::clockid_t, flags: ::c_int) -> ::c_int;
pub fn timerfd_gettime(
fd: ::c_int,
current_value: *mut itimerspec,
) -> ::c_int;
pub fn timerfd_settime(
fd: ::c_int,
flags: ::c_int,
new_value: *const itimerspec,
old_value: *mut itimerspec,
) -> ::c_int;
pub fn syscall(num: ::c_long, ...) -> ::c_long;
pub fn sched_getaffinity(
pid: ::pid_t,
@ -2460,6 +2594,11 @@ extern "C" {
buflen: ::size_t,
result: *mut *mut passwd,
) -> ::c_int;
pub fn sigtimedwait(
set: *const sigset_t,
info: *mut siginfo_t,
timeout: *const ::timespec,
) -> ::c_int;
pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
pub fn pthread_atfork(
prepare: ::Option<unsafe extern "C" fn()>,