aboutsummaryrefslogtreecommitdiff
path: root/src/unix/linux_like/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/unix/linux_like/mod.rs')
-rw-r--r--src/unix/linux_like/mod.rs508
1 files changed, 292 insertions, 216 deletions
diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs
index 792548f9..1cfc910a 100644
--- a/src/unix/linux_like/mod.rs
+++ b/src/unix/linux_like/mod.rs
@@ -50,6 +50,8 @@ s! {
pub sin6_scope_id: u32,
}
+ // The order of the `ai_addr` field in this struct is crucial
+ // for converting between the Rust and C types.
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
@@ -472,7 +474,7 @@ 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.
+// FIXME(#235): Include file sealing fcntls once we have a way to verify them.
pub const SIGTRAP: ::c_int = 5;
@@ -489,10 +491,7 @@ 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_TAI: ::clockid_t = 11;
pub const TIMER_ABSTIME: ::c_int = 1;
pub const RUSAGE_SELF: ::c_int = 0;
@@ -547,19 +546,24 @@ pub const PROT_READ: ::c_int = 1;
pub const PROT_WRITE: ::c_int = 2;
pub const PROT_EXEC: ::c_int = 4;
-pub const LC_CTYPE: ::c_int = 0;
-pub const LC_NUMERIC: ::c_int = 1;
-pub const LC_TIME: ::c_int = 2;
-pub const LC_COLLATE: ::c_int = 3;
-pub const LC_MONETARY: ::c_int = 4;
-pub const LC_MESSAGES: ::c_int = 5;
-pub const LC_ALL: ::c_int = 6;
-pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC);
-pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME);
-pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE);
-pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES);
+cfg_if! {
+ if #[cfg(not(target_env = "uclibc"))] {
+ pub const LC_CTYPE: ::c_int = 0;
+ pub const LC_NUMERIC: ::c_int = 1;
+ pub const LC_TIME: ::c_int = 2;
+ pub const LC_COLLATE: ::c_int = 3;
+ pub const LC_MONETARY: ::c_int = 4;
+ pub const LC_MESSAGES: ::c_int = 5;
+ pub const LC_ALL: ::c_int = 6;
+ }
+}
+
+pub const LC_CTYPE_MASK: ::c_int = 1 << LC_CTYPE;
+pub const LC_NUMERIC_MASK: ::c_int = 1 << LC_NUMERIC;
+pub const LC_TIME_MASK: ::c_int = 1 << LC_TIME;
+pub const LC_COLLATE_MASK: ::c_int = 1 << LC_COLLATE;
+pub const LC_MONETARY_MASK: ::c_int = 1 << LC_MONETARY;
+pub const LC_MESSAGES_MASK: ::c_int = 1 << LC_MESSAGES;
// LC_ALL_MASK defined per platform
pub const MAP_FILE: ::c_int = 0x0000;
@@ -602,42 +606,6 @@ pub const MS_ACTIVE: ::c_ulong = 0x40000000;
pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
-pub const EPERM: ::c_int = 1;
-pub const ENOENT: ::c_int = 2;
-pub const ESRCH: ::c_int = 3;
-pub const EINTR: ::c_int = 4;
-pub const EIO: ::c_int = 5;
-pub const ENXIO: ::c_int = 6;
-pub const E2BIG: ::c_int = 7;
-pub const ENOEXEC: ::c_int = 8;
-pub const EBADF: ::c_int = 9;
-pub const ECHILD: ::c_int = 10;
-pub const EAGAIN: ::c_int = 11;
-pub const ENOMEM: ::c_int = 12;
-pub const EACCES: ::c_int = 13;
-pub const EFAULT: ::c_int = 14;
-pub const ENOTBLK: ::c_int = 15;
-pub const EBUSY: ::c_int = 16;
-pub const EEXIST: ::c_int = 17;
-pub const EXDEV: ::c_int = 18;
-pub const ENODEV: ::c_int = 19;
-pub const ENOTDIR: ::c_int = 20;
-pub const EISDIR: ::c_int = 21;
-pub const EINVAL: ::c_int = 22;
-pub const ENFILE: ::c_int = 23;
-pub const EMFILE: ::c_int = 24;
-pub const ENOTTY: ::c_int = 25;
-pub const ETXTBSY: ::c_int = 26;
-pub const EFBIG: ::c_int = 27;
-pub const ENOSPC: ::c_int = 28;
-pub const ESPIPE: ::c_int = 29;
-pub const EROFS: ::c_int = 30;
-pub const EMLINK: ::c_int = 31;
-pub const EPIPE: ::c_int = 32;
-pub const EDOM: ::c_int = 33;
-pub const ERANGE: ::c_int = 34;
-pub const EWOULDBLOCK: ::c_int = EAGAIN;
-
pub const SCM_RIGHTS: ::c_int = 0x01;
pub const SCM_CREDENTIALS: ::c_int = 0x02;
@@ -805,20 +773,116 @@ pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
pub const SOCK_RAW: ::c_int = 3;
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_TOS: ::c_int = 1;
pub const IP_TTL: ::c_int = 2;
pub const IP_HDRINCL: ::c_int = 3;
+pub const IP_OPTIONS: ::c_int = 4;
+pub const IP_ROUTER_ALERT: ::c_int = 5;
+pub const IP_RECVOPTS: ::c_int = 6;
+pub const IP_RETOPTS: ::c_int = 7;
pub const IP_PKTINFO: ::c_int = 8;
-pub const IP_RECVTOS: ::c_int = 13;
+pub const IP_PKTOPTIONS: ::c_int = 9;
+pub const IP_MTU_DISCOVER: ::c_int = 10;
pub const IP_RECVERR: ::c_int = 11;
+pub const IP_RECVTTL: ::c_int = 12;
+pub const IP_RECVTOS: ::c_int = 13;
+pub const IP_MTU: ::c_int = 14;
+pub const IP_FREEBIND: ::c_int = 15;
+pub const IP_IPSEC_POLICY: ::c_int = 16;
+pub const IP_XFRM_POLICY: ::c_int = 17;
+pub const IP_PASSSEC: ::c_int = 18;
+pub const IP_TRANSPARENT: ::c_int = 19;
+pub const IP_ORIGDSTADDR: ::c_int = 20;
+pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR;
+pub const IP_MINTTL: ::c_int = 21;
+pub const IP_NODEFRAG: ::c_int = 22;
+pub const IP_CHECKSUM: ::c_int = 23;
+pub const IP_BIND_ADDRESS_NO_PORT: ::c_int = 24;
+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_ADD_MEMBERSHIP: ::c_int = 35;
pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
+pub const IP_UNBLOCK_SOURCE: ::c_int = 37;
+pub const IP_BLOCK_SOURCE: ::c_int = 38;
pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39;
pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40;
-pub const IP_TRANSPARENT: ::c_int = 19;
+pub const IP_MSFILTER: ::c_int = 41;
+pub const IP_MULTICAST_ALL: ::c_int = 49;
+pub const IP_UNICAST_IF: ::c_int = 50;
+
+pub const IP_DEFAULT_MULTICAST_TTL: ::c_int = 1;
+pub const IP_DEFAULT_MULTICAST_LOOP: ::c_int = 1;
+
+pub const IP_PMTUDISC_DONT: ::c_int = 0;
+pub const IP_PMTUDISC_WANT: ::c_int = 1;
+pub const IP_PMTUDISC_DO: ::c_int = 2;
+pub const IP_PMTUDISC_PROBE: ::c_int = 3;
+pub const IP_PMTUDISC_INTERFACE: ::c_int = 4;
+pub const IP_PMTUDISC_OMIT: ::c_int = 5;
+
+// IPPROTO_IP defined in src/unix/mod.rs
+/// Hop-by-hop option header
+pub const IPPROTO_HOPOPTS: ::c_int = 0;
+// IPPROTO_ICMP defined in src/unix/mod.rs
+/// group mgmt protocol
+pub const IPPROTO_IGMP: ::c_int = 2;
+/// for compatibility
+pub const IPPROTO_IPIP: ::c_int = 4;
+// IPPROTO_TCP defined in src/unix/mod.rs
+/// exterior gateway protocol
+pub const IPPROTO_EGP: ::c_int = 8;
+/// pup
+pub const IPPROTO_PUP: ::c_int = 12;
+// IPPROTO_UDP defined in src/unix/mod.rs
+/// xns idp
+pub const IPPROTO_IDP: ::c_int = 22;
+/// tp-4 w/ class negotiation
+pub const IPPROTO_TP: ::c_int = 29;
+/// DCCP
+pub const IPPROTO_DCCP: ::c_int = 33;
+// IPPROTO_IPV6 defined in src/unix/mod.rs
+/// IP6 routing header
+pub const IPPROTO_ROUTING: ::c_int = 43;
+/// IP6 fragmentation header
+pub const IPPROTO_FRAGMENT: ::c_int = 44;
+/// resource reservation
+pub const IPPROTO_RSVP: ::c_int = 46;
+/// General Routing Encap.
+pub const IPPROTO_GRE: ::c_int = 47;
+/// IP6 Encap Sec. Payload
+pub const IPPROTO_ESP: ::c_int = 50;
+/// IP6 Auth Header
+pub const IPPROTO_AH: ::c_int = 51;
+// IPPROTO_ICMPV6 defined in src/unix/mod.rs
+/// IP6 no next header
+pub const IPPROTO_NONE: ::c_int = 59;
+/// IP6 destination option
+pub const IPPROTO_DSTOPTS: ::c_int = 60;
+pub const IPPROTO_MTP: ::c_int = 92;
+/// encapsulation header
+pub const IPPROTO_ENCAP: ::c_int = 98;
+/// Protocol indep. multicast
+pub const IPPROTO_PIM: ::c_int = 103;
+/// IP Payload Comp. Protocol
+pub const IPPROTO_COMP: ::c_int = 108;
+/// SCTP
+pub const IPPROTO_SCTP: ::c_int = 132;
+pub const IPPROTO_MH: ::c_int = 135;
+pub const IPPROTO_UDPLITE: ::c_int = 136;
+/// raw IP packet
+pub const IPPROTO_RAW: ::c_int = 255;
+
+pub const MCAST_EXCLUDE: ::c_int = 0;
+pub const MCAST_INCLUDE: ::c_int = 1;
+pub const MCAST_JOIN_GROUP: ::c_int = 42;
+pub const MCAST_BLOCK_SOURCE: ::c_int = 43;
+pub const MCAST_UNBLOCK_SOURCE: ::c_int = 44;
+pub const MCAST_LEAVE_GROUP: ::c_int = 45;
+pub const MCAST_JOIN_SOURCE_GROUP: ::c_int = 46;
+pub const MCAST_LEAVE_SOURCE_GROUP: ::c_int = 47;
+pub const MCAST_MSFILTER: ::c_int = 48;
+
pub const IPV6_ADDRFORM: ::c_int = 1;
pub const IPV6_2292PKTINFO: ::c_int = 2;
pub const IPV6_2292HOPOPTS: ::c_int = 3;
@@ -828,7 +892,7 @@ pub const IPV6_2292PKTOPTIONS: ::c_int = 6;
pub const IPV6_CHECKSUM: ::c_int = 7;
pub const IPV6_2292HOPLIMIT: ::c_int = 8;
pub const IPV6_NEXTHOP: ::c_int = 9;
-pub const IPV6_FLOWINFO: ::c_int = 11;
+pub const IPV6_AUTHHDR: ::c_int = 10;
pub const IPV6_UNICAST_HOPS: ::c_int = 16;
pub const IPV6_MULTICAST_IF: ::c_int = 17;
pub const IPV6_MULTICAST_HOPS: ::c_int = 18;
@@ -842,10 +906,43 @@ pub const IPV6_RECVERR: ::c_int = 25;
pub const IPV6_V6ONLY: ::c_int = 26;
pub const IPV6_JOIN_ANYCAST: ::c_int = 27;
pub const IPV6_LEAVE_ANYCAST: ::c_int = 28;
+pub const IPV6_IPSEC_POLICY: ::c_int = 34;
+pub const IPV6_XFRM_POLICY: ::c_int = 35;
pub const IPV6_RECVPKTINFO: ::c_int = 49;
pub const IPV6_PKTINFO: ::c_int = 50;
+pub const IPV6_RECVHOPLIMIT: ::c_int = 51;
+pub const IPV6_HOPLIMIT: ::c_int = 52;
+pub const IPV6_RECVHOPOPTS: ::c_int = 53;
+pub const IPV6_HOPOPTS: ::c_int = 54;
+pub const IPV6_RTHDRDSTOPTS: ::c_int = 55;
+pub const IPV6_RECVRTHDR: ::c_int = 56;
+pub const IPV6_RTHDR: ::c_int = 57;
+pub const IPV6_RECVDSTOPTS: ::c_int = 58;
+pub const IPV6_DSTOPTS: ::c_int = 59;
+pub const IPV6_RECVPATHMTU: ::c_int = 60;
+pub const IPV6_PATHMTU: ::c_int = 61;
+pub const IPV6_DONTFRAG: ::c_int = 62;
pub const IPV6_RECVTCLASS: ::c_int = 66;
pub const IPV6_TCLASS: ::c_int = 67;
+pub const IPV6_AUTOFLOWLABEL: ::c_int = 70;
+pub const IPV6_ADDR_PREFERENCES: ::c_int = 72;
+pub const IPV6_MINHOPCOUNT: ::c_int = 73;
+pub const IPV6_ORIGDSTADDR: ::c_int = 74;
+pub const IPV6_RECVORIGDSTADDR: ::c_int = IPV6_ORIGDSTADDR;
+pub const IPV6_TRANSPARENT: ::c_int = 75;
+pub const IPV6_UNICAST_IF: ::c_int = 76;
+pub const IPV6_PREFER_SRC_TMP: ::c_int = 0x0001;
+pub const IPV6_PREFER_SRC_PUBLIC: ::c_int = 0x0002;
+pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: ::c_int = 0x0100;
+pub const IPV6_PREFER_SRC_COA: ::c_int = 0x0004;
+pub const IPV6_PREFER_SRC_HOME: ::c_int = 0x0400;
+pub const IPV6_PREFER_SRC_CGA: ::c_int = 0x0008;
+pub const IPV6_PREFER_SRC_NONCGA: ::c_int = 0x0800;
+
+pub const IPV6_PMTUDISC_DONT: ::c_int = 0;
+pub const IPV6_PMTUDISC_WANT: ::c_int = 1;
+pub const IPV6_PMTUDISC_DO: ::c_int = 2;
+pub const IPV6_PMTUDISC_PROBE: ::c_int = 3;
pub const TCP_NODELAY: ::c_int = 1;
pub const TCP_MAXSEG: ::c_int = 2;
@@ -877,6 +974,8 @@ pub const SS_DISABLE: ::c_int = 2;
pub const PATH_MAX: ::c_int = 4096;
+pub const UIO_MAXIOV: ::c_int = 1024;
+
pub const FD_SETSIZE: usize = 1024;
pub const EPOLLIN: ::c_int = 0x1;
@@ -982,7 +1081,6 @@ 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;
@@ -991,6 +1089,13 @@ pub const WEXITED: ::c_int = 0x00000004;
pub const WCONTINUED: ::c_int = 0x00000008;
pub const WNOWAIT: ::c_int = 0x01000000;
+// Options for personality(2).
+pub const MMAP_PAGE_ZERO: ::c_int = 0x0100000;
+pub const ADDR_LIMIT_32BIT: ::c_int = 0x0800000;
+pub const SHORT_INODE: ::c_int = 0x1000000;
+pub const WHOLE_SECONDS: ::c_int = 0x2000000;
+pub const STICKY_TIMEOUTS: ::c_int = 0x4000000;
+
// Options set using PTRACE_SETOPTIONS.
pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
@@ -1000,9 +1105,6 @@ 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;
@@ -1012,8 +1114,6 @@ 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;
@@ -1048,6 +1148,13 @@ pub const PIPE_BUF: usize = 4096;
pub const SI_LOAD_SHIFT: ::c_uint = 16;
+pub const CLD_EXITED: ::c_int = 1;
+pub const CLD_KILLED: ::c_int = 2;
+pub const CLD_DUMPED: ::c_int = 3;
+pub const CLD_TRAPPED: ::c_int = 4;
+pub const CLD_STOPPED: ::c_int = 5;
+pub const CLD_CONTINUED: ::c_int = 6;
+
pub const SIGEV_SIGNAL: ::c_int = 0;
pub const SIGEV_NONE: ::c_int = 1;
pub const SIGEV_THREAD: ::c_int = 2;
@@ -1055,6 +1162,11 @@ pub const SIGEV_THREAD: ::c_int = 2;
pub const P_ALL: idtype_t = 0;
pub const P_PID: idtype_t = 1;
pub const P_PGID: idtype_t = 2;
+cfg_if! {
+ if #[cfg(not(target_os = "emscripten"))] {
+ pub const P_PIDFD: idtype_t = 3;
+ }
+}
pub const UTIME_OMIT: c_long = 1073741822;
pub const UTIME_NOW: c_long = 1073741823;
@@ -1095,15 +1207,15 @@ pub const IPOPT_CONTROL: u8 = 0x00;
pub const IPOPT_RESERVED1: u8 = 0x20;
pub const IPOPT_MEASUREMENT: u8 = 0x40;
pub const IPOPT_RESERVED2: u8 = 0x60;
-pub const IPOPT_END: u8 = (0 | IPOPT_CONTROL);
-pub const IPOPT_NOOP: u8 = (1 | IPOPT_CONTROL);
-pub const IPOPT_SEC: u8 = (2 | IPOPT_CONTROL | IPOPT_COPY);
-pub const IPOPT_LSRR: u8 = (3 | IPOPT_CONTROL | IPOPT_COPY);
-pub const IPOPT_TIMESTAMP: u8 = (4 | IPOPT_MEASUREMENT);
-pub const IPOPT_RR: u8 = (7 | IPOPT_CONTROL);
-pub const IPOPT_SID: u8 = (8 | IPOPT_CONTROL | IPOPT_COPY);
-pub const IPOPT_SSRR: u8 = (9 | IPOPT_CONTROL | IPOPT_COPY);
-pub const IPOPT_RA: u8 = (20 | IPOPT_CONTROL | IPOPT_COPY);
+pub const IPOPT_END: u8 = 0 | IPOPT_CONTROL;
+pub const IPOPT_NOOP: u8 = 1 | IPOPT_CONTROL;
+pub const IPOPT_SEC: u8 = 2 | IPOPT_CONTROL | IPOPT_COPY;
+pub const IPOPT_LSRR: u8 = 3 | IPOPT_CONTROL | IPOPT_COPY;
+pub const IPOPT_TIMESTAMP: u8 = 4 | IPOPT_MEASUREMENT;
+pub const IPOPT_RR: u8 = 7 | IPOPT_CONTROL;
+pub const IPOPT_SID: u8 = 8 | IPOPT_CONTROL | IPOPT_COPY;
+pub const IPOPT_SSRR: u8 = 9 | IPOPT_CONTROL | IPOPT_COPY;
+pub const IPOPT_RA: u8 = 20 | IPOPT_CONTROL | IPOPT_COPY;
pub const IPVERSION: u8 = 4;
pub const MAXTTL: u8 = 255;
pub const IPDEFTTL: u8 = 64;
@@ -1189,6 +1301,24 @@ pub const ARPHRD_IEEE802154: u16 = 804;
pub const ARPHRD_VOID: u16 = 0xFFFF;
pub const ARPHRD_NONE: u16 = 0xFFFE;
+cfg_if! {
+ if #[cfg(not(target_env = "uclibc"))] {
+ pub const IPPROTO_BEETPH: ::c_int = 94;
+ pub const IPPROTO_MPLS: ::c_int = 137;
+ pub const IPV6_HDRINCL: ::c_int = 36;
+ pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4;
+ pub const IPV6_PMTUDISC_OMIT: ::c_int = 5;
+ pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
+ pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000;
+ pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000;
+ pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000;
+ pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000;
+ 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;
+ }
+}
+
const_fn! {
{const} fn CMSG_ALIGN(len: usize) -> usize {
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
@@ -1242,85 +1372,84 @@ f! {
*slot = 0;
}
}
+}
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
+safe_f! {
+ pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
(status & 0xff) == 0x7f
}
- pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
+ pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int {
(status >> 8) & 0xff
}
- pub fn WIFCONTINUED(status: ::c_int) -> bool {
+ pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0xffff
}
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
+ pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
((status & 0x7f) + 1) as i8 >= 2
}
- pub fn WTERMSIG(status: ::c_int) -> ::c_int {
+ pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int {
status & 0x7f
}
- pub fn WIFEXITED(status: ::c_int) -> bool {
+ pub {const} fn WIFEXITED(status: ::c_int) -> bool {
(status & 0x7f) == 0
}
- pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
+ pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int {
(status >> 8) & 0xff
}
- pub fn WCOREDUMP(status: ::c_int) -> bool {
+ pub {const} fn WCOREDUMP(status: ::c_int) -> bool {
(status & 0x80) != 0
}
- pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
+ pub {const} fn W_EXITCODE(ret: ::c_int, sig: ::c_int) -> ::c_int {
+ (ret << 8) | sig
+ }
+
+ pub {const} fn W_STOPCODE(sig: ::c_int) -> ::c_int {
+ (sig << 8) | 0x7f
+ }
+
+ pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int {
(cmd << 8) | (type_ & 0x00ff)
}
- pub fn IPOPT_COPIED(o: u8) -> u8 {
+ pub {const} fn IPOPT_COPIED(o: u8) -> u8 {
o & IPOPT_COPY
}
- pub fn IPOPT_CLASS(o: u8) -> u8 {
+ pub {const} fn IPOPT_CLASS(o: u8) -> u8 {
o & IPOPT_CLASS_MASK
}
- pub fn IPOPT_NUMBER(o: u8) -> u8 {
+ pub {const} fn IPOPT_NUMBER(o: u8) -> u8 {
o & IPOPT_NUMBER_MASK
}
- pub fn IPTOS_ECN(x: u8) -> u8 {
+ pub {const} fn IPTOS_ECN(x: u8) -> u8 {
x & ::IPTOS_ECN_MASK
}
}
extern "C" {
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_init(
- sem: *mut sem_t,
- pshared: ::c_int,
- value: ::c_uint,
- ) -> ::c_int;
+ pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::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 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_settime(
- clk_id: ::clockid_t,
- tp: *const ::timespec,
- ) -> ::c_int;
+ pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
+ pub fn clock_getcpuclockid(pid: ::pid_t, clk_id: *mut ::clockid_t) -> ::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_getattr_np(native: ::pthread_t, attr: *mut ::pthread_attr_t) -> ::c_int;
pub fn pthread_attr_getstack(
attr: *const ::pthread_attr_t,
stackaddr: *mut *mut ::c_void,
@@ -1335,16 +1464,13 @@ extern "C" {
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 memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
- pub fn posix_fadvise(
+ pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int;
+ pub fn posix_fadvise64(
fd: ::c_int,
- offset: ::off_t,
- len: ::off_t,
+ offset: ::off64_t,
+ len: ::off64_t,
advise: ::c_int,
) -> ::c_int;
pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
@@ -1356,11 +1482,7 @@ extern "C" {
) -> ::c_int;
pub fn duplocale(base: ::locale_t) -> ::locale_t;
pub fn freelocale(loc: ::locale_t);
- pub fn newlocale(
- mask: ::c_int,
- locale: *const ::c_char,
- base: ::locale_t,
- ) -> ::locale_t;
+ pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int;
pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int;
@@ -1382,36 +1504,14 @@ extern "C" {
offset: off64_t,
) -> *mut ::c_void;
pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
- pub fn openat64(
- fd: ::c_int,
- path: *const c_char,
- oflag: ::c_int,
- ...
- ) -> ::c_int;
- pub fn pread64(
- fd: ::c_int,
- buf: *mut ::c_void,
- count: ::size_t,
- offset: off64_t,
- ) -> ::ssize_t;
- pub fn preadv64(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t,
- ) -> ::ssize_t;
+ pub fn openat64(fd: ::c_int, path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
+ pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off64_t) -> ::ssize_t;
pub fn pwrite64(
fd: ::c_int,
buf: *const ::c_void,
count: ::size_t,
offset: off64_t,
) -> ::ssize_t;
- pub fn pwritev64(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- offset: ::off64_t,
- ) -> ::ssize_t;
pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
pub fn readdir64_r(
dirp: *mut ::DIR,
@@ -1435,16 +1535,7 @@ extern "C" {
attr: *mut pthread_condattr_t,
clock_id: ::clockid_t,
) -> ::c_int;
- pub fn pthread_condattr_setpshared(
- attr: *mut pthread_condattr_t,
- pshared: ::c_int,
- ) -> ::c_int;
- pub fn accept4(
- fd: ::c_int,
- addr: *mut ::sockaddr,
- len: *mut ::socklen_t,
- flg: ::c_int,
- ) -> ::c_int;
+ pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int;
pub fn pthread_mutexattr_setpshared(
attr: *mut pthread_mutexattr_t,
pshared: ::c_int,
@@ -1453,34 +1544,15 @@ extern "C" {
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 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 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 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;
@@ -1497,19 +1569,6 @@ extern "C" {
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 forkpty(
- amaster: *mut ::c_int,
- name: *mut ::c_char,
- termp: *const termios,
- winp: *const ::winsize,
- ) -> ::pid_t;
pub fn login_tty(fd: ::c_int) -> ::c_int;
pub fn execvpe(
file: *const ::c_char,
@@ -1523,43 +1582,60 @@ extern "C" {
) -> ::c_int;
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
- pub fn bind(
- socket: ::c_int,
- address: *const ::sockaddr,
- address_len: ::socklen_t,
- ) -> ::c_int;
+ pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
- pub fn writev(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- ) -> ::ssize_t;
- pub fn readv(
- fd: ::c_int,
- iov: *const ::iovec,
- iovcnt: ::c_int,
- ) -> ::ssize_t;
+ pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
+ pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
- pub fn sendmsg(
- fd: ::c_int,
- msg: *const ::msghdr,
- flags: ::c_int,
- ) -> ::ssize_t;
- pub fn recvmsg(
- fd: ::c_int,
- msg: *mut ::msghdr,
- flags: ::c_int,
- ) -> ::ssize_t;
+ pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
+ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
+ if #[cfg(not(target_env = "uclibc"))] {
+ extern "C" {
+ pub fn preadv64(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off64_t,
+ ) -> ::ssize_t;
+ pub fn pwritev64(
+ fd: ::c_int,
+ iov: *const ::iovec,
+ iovcnt: ::c_int,
+ offset: ::off64_t,
+ ) -> ::ssize_t;
+ // uclibc has separate non-const version of this function
+ pub fn forkpty(
+ amaster: *mut ::c_int,
+ name: *mut ::c_char,
+ termp: *const termios,
+ winp: *const ::winsize,
+ ) -> ::pid_t;
+ // uclibc has separate non-const version of this function
+ pub fn openpty(
+ amaster: *mut ::c_int,
+ aslave: *mut ::c_int,
+ name: *mut ::c_char,
+ termp: *const termios,
+ winp: *const ::winsize,
+ ) -> ::c_int;
+ }
+ }
+}
+
+cfg_if! {
if #[cfg(target_os = "emscripten")] {
mod emscripten;
pub use self::emscripten::*;
} else if #[cfg(target_os = "linux")] {
mod linux;
pub use self::linux::*;
+ } else if #[cfg(target_os = "l4re")] {
+ mod linux;
+ pub use self::linux::*;
} else if #[cfg(target_os = "android")] {
mod android;
pub use self::android::*;