summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-01-07 20:04:42 -0500
committerZack Weinberg <zackw@panix.com>2017-01-07 20:04:42 -0500
commit31d9779591bd1e2d6566788c98a66e2326c14ff1 (patch)
treed2a7997eb5ea9a62ae7642001188998671c92086
parentf1a91da7aa3127184a43dd3889af2f0ac3baf9e8 (diff)
downloadrust-libc-31d9779591bd1e2d6566788c98a66e2326c14ff1.tar.gz
Reorganize again; more portability fixes.
It turns out that *only* FreeBSD and NetBSD proper have waitid, and that Solaris' additional W* constants are totally different from everyone else's, which tips me over from 'find some way to shoehorn this into the top-level unix/mod.rs' to 'put it in the submodules, live with the code duplication'.
-rw-r--r--src/unix/bsd/apple/mod.rs16
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs20
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs6
-rw-r--r--src/unix/bsd/netbsdlike/netbsd/mod.rs15
-rw-r--r--src/unix/haiku/mod.rs19
-rw-r--r--src/unix/mod.rs35
-rw-r--r--src/unix/notbsd/mod.rs18
-rw-r--r--src/unix/solaris/mod.rs20
8 files changed, 108 insertions, 41 deletions
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index e80d4491fb..1a15245f4f 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -22,6 +22,12 @@ pub type nl_item = ::c_int;
pub type id_t = ::c_uint;
pub type sem_t = ::c_int;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+pub type idtype_t = ::c_uint;
+
pub enum timezone {}
s! {
@@ -1368,6 +1374,10 @@ pub const WSTOPPED: ::c_int = 0x00000008;
pub const WCONTINUED: ::c_int = 0x00000010;
pub const WNOWAIT: ::c_int = 0x00000020;
+pub const P_ALL: idtype_t = 0;
+pub const P_PID: idtype_t = 1;
+pub const P_PGID: idtype_t = 2;
+
f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
@@ -1537,6 +1547,12 @@ extern {
flags: ::c_int) -> ::c_int;
pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int;
+
+ #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
+ link_name = "waitid$UNIX2003")]
+ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
+ options: ::c_int) -> ::c_int;
+
}
cfg_if! {
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index ba56d1e13e..b4e9ac6616 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -10,6 +10,12 @@ pub type sem_t = _sem;
pub type fsblkcnt_t = ::uint64_t;
pub type fsfilcnt_t = ::uint64_t;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+pub type idtype_t = ::c_uint;
+
s! {
pub struct utmpx {
pub ut_type: ::c_short,
@@ -356,6 +362,18 @@ pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
| LC_NUMERIC_MASK
| LC_TIME_MASK;
+pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED
+pub const WCONTINUED: ::c_int = 4;
+pub const WNOWAIT: ::c_int = 8;
+pub const WEXITED: ::c_int = 16;
+pub const WTRAPPED: ::c_int = 32;
+
+// FreeBSD defines a great many more of these, we only expose the
+// standardized ones.
+pub const P_PID: idtype_t = 0;
+pub const P_PGID: idtype_t = 2;
+pub const P_ALL: idtype_t = 7;
+
extern {
pub fn __error() -> *mut ::c_int;
@@ -382,6 +400,8 @@ extern {
timeout: *mut ::timespec) -> ::ssize_t;
pub fn freelocale(loc: ::locale_t) -> ::c_int;
+ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
+ options: ::c_int) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 8f75c3b7bf..9fa9ebad04 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -693,12 +693,6 @@ pub const TIOCSWINSZ: ::c_ulong = 0x80087467;
pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t;
-pub const WSTOPPED: ::c_int = 2; // same as WUNTRACED
-pub const WCONTINUED: ::c_int = 4;
-pub const WNOWAIT: ::c_int = 8;
-pub const WEXITED: ::c_int = 16;
-pub const WTRAPPED: ::c_int = 32;
-
f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index 4a8492cadc..52fd465244 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -5,6 +5,12 @@ pub type blksize_t = ::int32_t;
pub type fsblkcnt_t = ::uint64_t;
pub type fsfilcnt_t = ::uint64_t;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+pub type idtype_t = ::c_int;
+
s! {
pub struct aiocb {
pub aio_offset: ::off_t,
@@ -588,6 +594,10 @@ pub const WCONTINUED: ::c_int = 0x00000010;
pub const WEXITED: ::c_int = 0x000000020;
pub const WNOWAIT: ::c_int = 0x00010000;
+pub const P_ALL: idtype_t = 0;
+pub const P_PID: idtype_t = 1;
+pub const P_PGID: idtype_t = 4;
+
extern {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
@@ -663,6 +673,11 @@ extern {
pub fn newlocale(mask: ::c_int,
locale: *const ::c_char,
base: ::locale_t) -> ::locale_t;
+
+ // This should work, but it causes the netbsd CI build to fail with an
+ // intra-libc.a undefined reference to `wait6`.
+ //pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
+ // options: ::c_int) -> ::c_int;
}
mod other;
diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs
index ab53e6c788..0a6771bece 100644
--- a/src/unix/haiku/mod.rs
+++ b/src/unix/haiku/mod.rs
@@ -29,6 +29,12 @@ pub type fsfilcnt_t = i64;
pub type pthread_attr_t = *mut ::c_void;
pub type nl_item = ::c_int;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+pub type idtype_t = ::c_uint;
+
pub enum timezone {}
s! {
@@ -670,6 +676,17 @@ pub const SO_PEERCRED: ::c_int = 0x4000000b;
pub const NI_MAXHOST: ::size_t = 1025;
+pub const WNOHANG: ::c_int = 0x01;
+pub const WUNTRACED: ::c_int = 0x02;
+pub const WCONTINUED: ::c_int = 0x04;
+pub const WEXITED: ::c_int = 0x08;
+pub const WSTOPPED: ::c_int = 0x10;
+pub const WNOWAIT: ::c_int = 0x20;
+
+pub const P_ALL: idtype_t = 0;
+pub const P_PID: idtype_t = 1;
+pub const P_PGID: idtype_t = 2;
+
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
@@ -742,6 +759,8 @@ extern {
flags: ::c_int) -> ::c_int;
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
abstime: *const ::timespec) -> ::c_int;
+ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
+ options: ::c_int) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index e0cf1463f4..f88ed6dcc2 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -16,20 +16,6 @@ pub type cc_t = ::c_uchar;
pub enum DIR {}
pub enum locale_t {}
-// idtype_t is specified as a C enum:
-// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
-// However, FFI doesn't currently know how to ABI-match a C enum
-// (rust#28925, rust#34641).
-cfg_if! {
- if #[cfg(target_os = "openbsd")] {
- // idtype_t is not available
- } else if #[cfg(target_os = "android")] {
- pub type idtype_t = ::c_int;
- } else {
- pub type idtype_t = ::c_uint;
- }
-}
-
s! {
pub struct group {
pub gr_name: *mut ::c_char,
@@ -218,22 +204,6 @@ pub const PRIO_MIN: ::c_int = -20;
pub const PRIO_MAX: ::c_int = 20;
cfg_if! {
- if #[cfg(target_os = "openbsd")] {
- // P_* constants are not available
- } else if #[cfg(target_os = "freebsd")] {
- // FreeBSD defines a great many more of these, and gives the
- // standardized constants different values from everyone else.
- pub const P_PID: idtype_t = 0;
- pub const P_PGID: idtype_t = 2;
- pub const P_ALL: idtype_t = 7;
- } else {
- 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(dox)] {
// on dox builds don't pull in anything
} else if #[cfg(all(not(stdbuild), feature = "use_std"))] {
@@ -477,11 +447,6 @@ extern {
link_name = "waitpid$UNIX2003")]
pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int)
-> pid_t;
- #[cfg(not(any(target_os = "openbsd", target_os = "netbsd")))] // " if "
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "waitid$UNIX2003")]
- pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
- options: ::c_int) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "write$UNIX2003")]
pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t)
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index 39ad6d79c0..1132fe380c 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -9,6 +9,18 @@ pub type clockid_t = ::c_int;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+cfg_if! {
+ if #[cfg(target_os = "android")] {
+ pub type idtype_t = ::c_int;
+ } else {
+ pub type idtype_t = ::c_uint;
+ }
+}
+
pub enum timezone {}
s! {
@@ -624,6 +636,10 @@ pub const SIGEV_SIGNAL: ::c_int = 0;
pub const SIGEV_NONE: ::c_int = 1;
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;
+
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
@@ -851,6 +867,8 @@ extern {
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;
}
cfg_if! {
diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs
index 3810fc57f2..53d0be8914 100644
--- a/src/unix/solaris/mod.rs
+++ b/src/unix/solaris/mod.rs
@@ -33,6 +33,12 @@ pub type blksize_t = u32;
pub type fflags_t = u32;
pub type nl_item = ::c_int;
+// idtype_t is specified as a C enum:
+// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
+// However, FFI doesn't currently know how to ABI-match a C enum
+// (rust#28925, rust#34641).
+pub type idtype_t = ::c_uint;
+
pub enum timezone {}
s! {
@@ -550,6 +556,18 @@ pub const SIGXFSZ: ::c_int = 31;
pub const WNOHANG: ::c_int = 0x40;
pub const WUNTRACED: ::c_int = 0x04;
+pub const WEXITED: ::c_int = 0x01;
+pub const WTRAPPED: ::c_int = 0x02;
+pub const WSTOPPED: ::c_int = WUNTRACED;
+pub const WCONTINUED: ::c_int = 0x08;
+pub const WNOWAIT: ::c_int = 0x80;
+
+// Solaris defines a great many more of these; we only expose the
+// standardized ones.
+pub const P_PID: idtype_t = 0;
+pub const P_PGID: idtype_t = 2;
+pub const P_ALL: idtype_t = 7;
+
pub const PROT_NONE: ::c_int = 0;
pub const PROT_READ: ::c_int = 1;
pub const PROT_WRITE: ::c_int = 2;
@@ -1056,4 +1074,6 @@ extern {
abstime: *const ::timespec) -> ::c_int;
pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
abstime: *const ::timespec) -> ::c_int;
+ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
+ options: ::c_int) -> ::c_int;
}