From 9d1e4848d5deabcfaa0f0ccdafe74273337d4fdd Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Fri, 6 Jan 2017 12:04:25 -0500 Subject: [PATCH 1/7] Add waitid and related constants and types. waitid() is a variation on waitpid() with a marginally more convenient way of reporting the status, and a couple of handy additional features, such as the ability to peek at an exit status without consuming it. It's in POSIX.1-2008 and should be available on all supported Unixes. Along with it come the type 'idtype_t' and the constants WEXITED, WSTOPPED, WCONTINUED, and WNOWAIT. Theconstants were alre dy defined for unix/notbsd platforms. Patch incomplete: several targets are going to have to add definitions of siginfo_t, but I'm not sure which ones yet. --- src/unix/bsd/mod.rs | 4 ++++ src/unix/mod.rs | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index c7997ef5e951f..967acc7eb0651 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -271,6 +271,10 @@ pub const NOFLSH: ::tcflag_t = 0x80000000; pub const WNOHANG: ::c_int = 0x00000001; pub const WUNTRACED: ::c_int = 0x00000002; +pub const WEXITED: ::c_int = 0x00000004; +pub const WSTOPPED: ::c_int = 0x00000008; +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WNOWAIT: ::c_int = 0x00000020; pub const RTLD_NOW: ::c_int = 0x2; pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index f88ed6dcc2b65..222da5c7d3ac4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -16,6 +16,13 @@ pub type cc_t = ::c_uchar; pub enum DIR {} pub enum locale_t {} +#[repr(C)] +pub enum idtype_t { + P_ALL = 0, + P_PID = 1, + P_PGID = 2, +} + s! { pub struct group { pub gr_name: *mut ::c_char, @@ -447,6 +454,8 @@ extern { link_name = "waitpid$UNIX2003")] pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t; + 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) From 644929ad10a2c82911a34c7581b53234c7224ad7 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Fri, 6 Jan 2017 16:01:19 -0500 Subject: [PATCH 2/7] Corrections based on CI failures. * idtype_t no longer an enum. * Darwin/x86-32 needs the $UNIX2003 thing. * Darwin, FreeBSD, and NetBSD all have different values for the new constants. * OpenBSD doesn't have this feature at all. (Hopefully we can get away with defining idtype_t anyway.) --- src/unix/bsd/apple/mod.rs | 5 +++++ src/unix/bsd/freebsdlike/mod.rs | 6 ++++++ src/unix/bsd/mod.rs | 4 ---- src/unix/bsd/netbsdlike/netbsd/mod.rs | 5 +++++ src/unix/mod.rs | 19 +++++++++++++------ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 0eaaced03ec2a..e80d4491fb362 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1363,6 +1363,11 @@ pub const LIO_READ: ::c_int = 1; pub const LIO_WAIT: ::c_int = 2; pub const LIO_NOWAIT: ::c_int = 1; +pub const WEXITED: ::c_int = 0x00000004; +pub const WSTOPPED: ::c_int = 0x00000008; +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WNOWAIT: ::c_int = 0x00000020; + f! { pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 9fa9ebad04fd9..8f75c3b7bf890 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -693,6 +693,12 @@ 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/mod.rs b/src/unix/bsd/mod.rs index 967acc7eb0651..c7997ef5e951f 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -271,10 +271,6 @@ pub const NOFLSH: ::tcflag_t = 0x80000000; pub const WNOHANG: ::c_int = 0x00000001; pub const WUNTRACED: ::c_int = 0x00000002; -pub const WEXITED: ::c_int = 0x00000004; -pub const WSTOPPED: ::c_int = 0x00000008; -pub const WCONTINUED: ::c_int = 0x00000010; -pub const WNOWAIT: ::c_int = 0x00000020; pub const RTLD_NOW: ::c_int = 0x2; pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 57a34130c919c..4a8492cadc25d 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -583,6 +583,11 @@ pub const SIGEV_NONE: ::c_int = 0; pub const SIGEV_SIGNAL: ::c_int = 1; pub const SIGEV_THREAD: ::c_int = 2; +pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED +pub const WCONTINUED: ::c_int = 0x00000010; +pub const WEXITED: ::c_int = 0x000000020; +pub const WNOWAIT: ::c_int = 0x00010000; + extern { pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 222da5c7d3ac4..8315151b81327 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -16,12 +16,12 @@ pub type cc_t = ::c_uchar; pub enum DIR {} pub enum locale_t {} -#[repr(C)] -pub enum idtype_t { - P_ALL = 0, - P_PID = 1, - P_PGID = 2, -} +// FIXME: This is technically wrong; 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) and *probably* the underlying type will be +// c_uint everywhere since all of the enumerators are representable by c_uint. +pub type idtype_t = ::c_uint; s! { pub struct group { @@ -210,6 +210,10 @@ pub const PRIO_USER: ::c_int = 2; pub const PRIO_MIN: ::c_int = -20; pub const PRIO_MAX: ::c_int = 20; +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 @@ -454,6 +458,9 @@ extern { link_name = "waitpid$UNIX2003")] pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t; + #[cfg(not(target_os = "openbsd"))] // " if " -- appease style checker + #[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"), From f1a91da7aa3127184a43dd3889af2f0ac3baf9e8 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Fri, 6 Jan 2017 18:55:32 -0500 Subject: [PATCH 3/7] Another round of portability fixes: * OpenBSD doesn't have idtype_t or the P_* constants either * FreeBSD has different values for the P_* constants * Android gives idtype_t a different signedness * Disable waitid on NetBSD as it causes a link failure - I think this may be a problem with the test environment --- src/unix/mod.rs | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8315151b81327..e0cf1463f4442 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -16,12 +16,19 @@ pub type cc_t = ::c_uchar; pub enum DIR {} pub enum locale_t {} -// FIXME: This is technically wrong; idtype_t is specified as a C enum. -// [ http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html ] +// 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) and *probably* the underlying type will be -// c_uint everywhere since all of the enumerators are representable by c_uint. -pub type idtype_t = ::c_uint; +// (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 { @@ -210,9 +217,21 @@ pub const PRIO_USER: ::c_int = 2; pub const PRIO_MIN: ::c_int = -20; pub const PRIO_MAX: ::c_int = 20; -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(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)] { @@ -458,7 +477,7 @@ extern { link_name = "waitpid$UNIX2003")] pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) -> pid_t; - #[cfg(not(target_os = "openbsd"))] // " if " -- appease style checker + #[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, From 31d9779591bd1e2d6566788c98a66e2326c14ff1 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sat, 7 Jan 2017 20:04:42 -0500 Subject: [PATCH 4/7] 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'. --- src/unix/bsd/apple/mod.rs | 16 +++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 20 ++++++++++++++ src/unix/bsd/freebsdlike/mod.rs | 6 ----- src/unix/bsd/netbsdlike/netbsd/mod.rs | 15 +++++++++++ src/unix/haiku/mod.rs | 19 ++++++++++++++ src/unix/mod.rs | 35 ------------------------- src/unix/notbsd/mod.rs | 18 +++++++++++++ src/unix/solaris/mod.rs | 20 ++++++++++++++ 8 files changed, 108 insertions(+), 41 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index e80d4491fb362..1a15245f4f287 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 ba56d1e13e781..b4e9ac6616427 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 8f75c3b7bf890..9fa9ebad04fd9 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 4a8492cadc25d..52fd4652448d7 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 ab53e6c788c68..0a6771becea7f 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 e0cf1463f4442..f88ed6dcc2b65 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, @@ -217,22 +203,6 @@ pub const PRIO_USER: ::c_int = 2; 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 @@ -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 39ad6d79c0d76..1132fe380cc73 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 3810fc57f2132..53d0be8914a93 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; } From f05e48cfb5fa68273d0bb2a5555d8c03e1366acf Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sat, 7 Jan 2017 20:52:47 -0500 Subject: [PATCH 5/7] Patch in id_t missing in a few places --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 +- src/unix/haiku/mod.rs | 1 + src/unix/solaris/mod.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index b4e9ac6616427..ba5213d2bf068 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -400,7 +400,7 @@ 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, + pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 0a6771becea7f..588a7ee6bd973 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -28,6 +28,7 @@ pub type fsblkcnt_t = i64; pub type fsfilcnt_t = i64; pub type pthread_attr_t = *mut ::c_void; pub type nl_item = ::c_int; +pub type id_t = i32; // idtype_t is specified as a C enum: // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 53d0be8914a93..65e4b3c56876e 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -32,6 +32,7 @@ pub type pthread_key_t = ::c_uint; pub type blksize_t = u32; pub type fflags_t = u32; pub type nl_item = ::c_int; +pub type id_t = ::c_int; // idtype_t is specified as a C enum: // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html From 984fb54d832f2101b3522658fc360a66e2212ab9 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 10 Jan 2017 11:09:51 -0500 Subject: [PATCH 6/7] Changes requested by reviewers --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 5 ----- src/unix/bsd/netbsdlike/netbsd/mod.rs | 10 ---------- src/unix/haiku/mod.rs | 5 ----- src/unix/notbsd/android/mod.rs | 1 + src/unix/notbsd/linux/mod.rs | 1 + src/unix/notbsd/mod.rs | 12 ------------ src/unix/solaris/mod.rs | 5 ----- 7 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ba5213d2bf068..4d5a4cfa0d676 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -9,11 +9,6 @@ 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! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 52fd4652448d7..2f85513408b2f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -4,11 +4,6 @@ pub type dev_t = u64; 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! { @@ -673,11 +668,6 @@ 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 588a7ee6bd973..86e590912857d 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -29,11 +29,6 @@ pub type fsfilcnt_t = i64; pub type pthread_attr_t = *mut ::c_void; pub type nl_item = ::c_int; pub type id_t = i32; - -// 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 {} diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 8a1b565d620fe..4b4e26222ad62 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -25,6 +25,7 @@ pub type rlim_t = ::c_ulong; pub type dev_t = ::c_ulong; pub type ino_t = ::c_ulong; pub type __CPU_BITTYPE = ::c_ulong; +pub type idtype_t = ::c_int; s! { pub struct dirent { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index f822a2faa2cfe..13b61df2cde06 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -17,6 +17,7 @@ pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type nfds_t = ::c_ulong; pub type nl_item = ::c_int; +pub type idtype_t = ::c_uint; pub enum fpos64_t {} // TODO: fill this out with a struct diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 1132fe380cc73..0233d266e917e 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -9,18 +9,6 @@ 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! { diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 65e4b3c56876e..b604208583a40 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -33,11 +33,6 @@ pub type blksize_t = u32; pub type fflags_t = u32; pub type nl_item = ::c_int; pub type id_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 {} From 84bce949d697decd757fe362c99a10c8f82a81f4 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 10 Jan 2017 13:08:19 -0500 Subject: [PATCH 7/7] Remove remaining copy of the comment about idtype_t being an enum. --- src/unix/bsd/apple/mod.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 1a15245f4f287..a4b6c9b4e86f2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -21,11 +21,6 @@ pub type tcflag_t = ::c_ulong; 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 {}