diff options
Diffstat (limited to 'libc/src/unix/notbsd/mod.rs')
-rw-r--r-- | libc/src/unix/notbsd/mod.rs | 232 |
1 files changed, 115 insertions, 117 deletions
diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs index b20d043..66437de 100644 --- a/libc/src/unix/notbsd/mod.rs +++ b/libc/src/unix/notbsd/mod.rs @@ -4,7 +4,6 @@ pub type sa_family_t = u16; pub type pthread_key_t = ::c_uint; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; -pub type loff_t = ::c_longlong; pub type clockid_t = ::c_int; pub type key_t = ::c_int; pub type id_t = ::c_uint; @@ -103,13 +102,13 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_low_priority: ::c_int, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl"))] + #[cfg(any(target_env = "musl", target_os = "emscripten"))] pub sched_ss_max_repl: ::c_int, } @@ -212,9 +211,17 @@ pub const F_SETFL: ::c_int = 4; pub const F_SETLEASE: ::c_int = 1024; pub const F_GETLEASE: ::c_int = 1025; pub const F_NOTIFY: ::c_int = 1026; +pub const F_CANCELLK: ::c_int = 1029; pub const F_DUPFD_CLOEXEC: ::c_int = 1030; pub const F_SETPIPE_SZ: ::c_int = 1031; pub const F_GETPIPE_SZ: ::c_int = 1032; +pub const F_ADD_SEALS: ::c_int = 1033; +pub const F_GET_SEALS: ::c_int = 1034; + +pub const F_SEAL_SEAL: ::c_int = 0x0001; +pub const F_SEAL_SHRINK: ::c_int = 0x0002; +pub const F_SEAL_GROW: ::c_int = 0x0004; +pub const F_SEAL_WRITE: ::c_int = 0x0008; // TODO(#235): Include file sealing fcntls once we have a way to verify them. @@ -223,20 +230,20 @@ pub const SIGTRAP: ::c_int = 5; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; -pub const CLOCK_REALTIME: clockid_t = 0; -pub const CLOCK_MONOTONIC: clockid_t = 1; -pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; -pub const CLOCK_MONOTONIC_RAW: clockid_t = 4; -pub const CLOCK_REALTIME_COARSE: clockid_t = 5; -pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; -pub const CLOCK_BOOTTIME: clockid_t = 7; -pub const CLOCK_REALTIME_ALARM: clockid_t = 8; -pub const CLOCK_BOOTTIME_ALARM: clockid_t = 9; +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_MONOTONIC: ::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6; +pub const CLOCK_BOOTTIME: ::clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9; // TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep // 2014.) See also musl/mod.rs -// pub const CLOCK_SGI_CYCLE: clockid_t = 10; -// pub const CLOCK_TAI: clockid_t = 11; +// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; +// pub const CLOCK_TAI: ::clockid_t = 11; pub const TIMER_ABSTIME: ::c_int = 1; pub const RLIMIT_CPU: ::c_int = 0; @@ -255,7 +262,6 @@ pub const RUSAGE_SELF: ::c_int = 0; pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; -pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; @@ -411,12 +417,18 @@ pub const MADV_RANDOM: ::c_int = 1; pub const MADV_SEQUENTIAL: ::c_int = 2; pub const MADV_WILLNEED: ::c_int = 3; pub const MADV_DONTNEED: ::c_int = 4; +pub const MADV_FREE: ::c_int = 8; pub const MADV_REMOVE: ::c_int = 9; pub const MADV_DONTFORK: ::c_int = 10; pub const MADV_DOFORK: ::c_int = 11; pub const MADV_MERGEABLE: ::c_int = 12; pub const MADV_UNMERGEABLE: ::c_int = 13; +pub const MADV_HUGEPAGE: ::c_int = 14; +pub const MADV_NOHUGEPAGE: ::c_int = 15; +pub const MADV_DONTDUMP: ::c_int = 16; +pub const MADV_DODUMP: ::c_int = 17; pub const MADV_HWPOISON: ::c_int = 100; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const IFF_UP: ::c_int = 0x1; pub const IFF_BROADCAST: ::c_int = 0x2; @@ -437,6 +449,7 @@ pub const IFF_DYNAMIC: ::c_int = 0x8000; pub const SOL_IP: ::c_int = 0; pub const SOL_TCP: ::c_int = 6; +pub const SOL_UDP: ::c_int = 17; pub const SOL_IPV6: ::c_int = 41; pub const SOL_ICMPV6: ::c_int = 58; pub const SOL_RAW: ::c_int = 255; @@ -553,12 +566,11 @@ pub const MSG_WAITFORONE: ::c_int = 0x10000; pub const MSG_FASTOPEN: ::c_int = 0x20000000; pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; +pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; + pub const SOCK_RAW: ::c_int = 3; -pub const IPPROTO_ICMP: ::c_int = 1; -pub const IPPROTO_ICMPV6: ::c_int = 58; -pub const IPPROTO_TCP: ::c_int = 6; -pub const IPPROTO_IP: ::c_int = 0; -pub const IPPROTO_IPV6: ::c_int = 41; +pub const SOCK_RDM: ::c_int = 4; +pub const IP_MULTICAST_IF: ::c_int = 32; pub const IP_MULTICAST_TTL: ::c_int = 33; pub const IP_MULTICAST_LOOP: ::c_int = 34; pub const IP_TTL: ::c_int = 2; @@ -675,11 +687,15 @@ pub const IGNCR: ::tcflag_t = 0x00000080; pub const ICRNL: ::tcflag_t = 0x00000100; pub const IXANY: ::tcflag_t = 0x00000800; pub const IMAXBEL: ::tcflag_t = 0x00002000; -pub const IUTF8: ::tcflag_t = 0x00004000; pub const OPOST: ::tcflag_t = 0x1; pub const CS5: ::tcflag_t = 0x00000000; pub const CRTSCTS: ::tcflag_t = 0x80000000; pub const ECHO: ::tcflag_t = 0x00000008; +pub const OCRNL: ::tcflag_t = 0o000010; +pub const ONOCR: ::tcflag_t = 0o000020; +pub const ONLRET: ::tcflag_t = 0o000040; +pub const OFILL: ::tcflag_t = 0o000100; +pub const OFDEL: ::tcflag_t = 0o000200; pub const CLONE_VM: ::c_int = 0x100; pub const CLONE_FS: ::c_int = 0x200; @@ -703,6 +719,7 @@ pub const CLONE_NEWUSER: ::c_int = 0x10000000; pub const CLONE_NEWPID: ::c_int = 0x20000000; pub const CLONE_NEWNET: ::c_int = 0x40000000; pub const CLONE_IO: ::c_int = 0x80000000; +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; pub const WNOHANG: ::c_int = 0x00000001; pub const WUNTRACED: ::c_int = 0x00000002; @@ -711,6 +728,30 @@ pub const WEXITED: ::c_int = 0x00000004; pub const WCONTINUED: ::c_int = 0x00000008; pub const WNOWAIT: ::c_int = 0x01000000; +// Options set using PTRACE_SETOPTIONS. +pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; +pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002; +pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004; +pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008; +pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; +pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; +pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; +pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; +pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; +pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; +pub const PTRACE_O_MASK: ::c_int = 0x003000ff; + +// Wait extended result codes for the above trace options. +pub const PTRACE_EVENT_FORK: ::c_int = 1; +pub const PTRACE_EVENT_VFORK: ::c_int = 2; +pub const PTRACE_EVENT_CLONE: ::c_int = 3; +pub const PTRACE_EVENT_EXEC: ::c_int = 4; +pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5; +pub const PTRACE_EVENT_EXIT: ::c_int = 6; +pub const PTRACE_EVENT_SECCOMP: ::c_int = 7; +// PTRACE_EVENT_STOP was added to glibc in 2.26 +// pub const PTRACE_EVENT_STOP: ::c_int = 128; + pub const __WNOTHREAD: ::c_int = 0x20000000; pub const __WALL: ::c_int = 0x40000000; pub const __WCLONE: ::c_int = 0x80000000; @@ -754,6 +795,9 @@ pub const P_PGID: idtype_t = 2; pub const UTIME_OMIT: c_long = 1073741822; pub const UTIME_NOW: c_long = 1073741823; +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLRDBAND: ::c_short = 0x080; + f! { pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; @@ -815,90 +859,32 @@ f! { } extern { - pub fn getpwnam_r(name: *const ::c_char, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::size_t, - result: *mut *mut passwd) -> ::c_int; - pub fn getpwuid_r(uid: ::uid_t, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::size_t, - result: *mut *mut passwd) -> ::c_int; pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; - pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_nanosleep(clk_id: clockid_t, - flags: ::c_int, - rqtp: *const ::timespec, - rmtp: *mut ::timespec) -> ::c_int; - pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int; - pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn pthread_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int; - pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, - guardsize: *mut ::size_t) -> ::c_int; pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, stacksize: *mut ::size_t) -> ::c_int; pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn setgroups(ngroups: ::size_t, ptr: *const ::gid_t) -> ::c_int; - pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; - pub fn sched_setscheduler(pid: ::pid_t, - policy: ::c_int, - param: *const sched_param) -> ::c_int; - pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; - pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; - pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; - pub fn epoll_create(size: ::c_int) -> ::c_int; - pub fn epoll_create1(flags: ::c_int) -> ::c_int; - pub fn epoll_ctl(epfd: ::c_int, - op: ::c_int, - fd: ::c_int, - event: *mut epoll_event) -> ::c_int; - pub fn epoll_wait(epfd: ::c_int, - events: *mut epoll_event, - maxevents: ::c_int, - timeout: ::c_int) -> ::c_int; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; - pub fn mount(src: *const ::c_char, - target: *const ::c_char, - fstype: *const ::c_char, - flags: ::c_ulong, - data: *const ::c_void) -> ::c_int; - pub fn umount(target: *const ::c_char) -> ::c_int; - pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; - pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, - child_stack: *mut ::c_void, - flags: ::c_int, - arg: *mut ::c_void, ...) -> ::c_int; pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int; pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int; + pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int; + pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; - pub fn syscall(num: ::c_long, ...) -> ::c_long; - pub fn sendfile(out_fd: ::c_int, - in_fd: ::c_int, - offset: *mut off_t, - count: ::size_t) -> ::ssize_t; - pub fn splice(fd_in: ::c_int, - off_in: *mut ::loff_t, - fd_out: ::c_int, - off_out: *mut ::loff_t, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn tee(fd_in: ::c_int, - fd_out: ::c_int, - len: ::size_t, - flags: ::c_uint) -> ::ssize_t; - pub fn vmsplice(fd: ::c_int, - iov: *const ::iovec, - nr_segs: ::size_t, - flags: ::c_uint) -> ::ssize_t; pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; @@ -938,55 +924,62 @@ extern { pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; - pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; - pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int; pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; - pub fn ppoll(fds: *mut ::pollfd, - nfds: nfds_t, - timeout: *const ::timespec, - sigmask: *const sigset_t) -> ::c_int; pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, clock_id: *mut clockid_t) -> ::c_int; pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, - clock_id: clockid_t) -> ::c_int; + clock_id: ::clockid_t) -> ::c_int; pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int; - pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, - pshared: *mut ::c_int) -> ::c_int; - pub fn sched_getaffinity(pid: ::pid_t, - cpusetsize: ::size_t, - cpuset: *mut cpu_set_t) -> ::c_int; - pub fn sched_setaffinity(pid: ::pid_t, - cpusetsize: ::size_t, - cpuset: *const cpu_set_t) -> ::c_int; - pub fn unshare(flags: ::c_int) -> ::c_int; - pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; - pub fn sem_timedwait(sem: *mut sem_t, - abstime: *const ::timespec) -> ::c_int; pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t, flg: ::c_int) -> ::c_int; - pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, - abstime: *const ::timespec) -> ::c_int; pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: ::c_int) -> ::c_int; - pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, - pshared: *mut ::c_int) -> ::c_int; + pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, + val: *mut ::c_int) -> ::c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, + val: ::c_int) -> ::c_int; pub fn ptsname_r(fd: ::c_int, buf: *mut ::c_char, buflen: ::size_t) -> ::c_int; pub fn clearenv() -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; + pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int; + pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int; + pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, + suid: *mut ::uid_t) -> ::c_int; + pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, + sgid: *mut ::gid_t) -> ::c_int; + pub fn acct(filename: *const ::c_char) -> ::c_int; + pub fn brk(addr: *mut ::c_void) -> ::c_int; + pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; + pub fn vfork() -> ::pid_t; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn wait4(pid: ::pid_t, status: *mut ::c_int, options: ::c_int, + rusage: *mut ::rusage) -> ::pid_t; + pub fn openpty(amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize) -> ::c_int; + pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, + envp: *const *const ::c_char) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, + envp: *const *const ::c_char) + -> ::c_int; } cfg_if! { - if #[cfg(any(target_os = "linux", - target_os = "emscripten", - target_os = "fuchsia"))] { + if #[cfg(target_os = "emscripten")] { + mod emscripten; + pub use self::emscripten::*; + } else if #[cfg(any(target_os = "linux", target_os = "fuchsia"))] { mod linux; pub use self::linux::*; } else if #[cfg(target_os = "android")] { @@ -996,3 +989,8 @@ cfg_if! { // Unknown target_os } } + // pub fn forkpty(amaster: *mut ::c_int, + // name: *mut ::c_char, + // termp: *const termios, + // winp: *const ::winsize) -> ::pid_t; + // pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; |