-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add waitid and related constants and types. #489
Changes from 5 commits
9d1e484
644929a
f1a91da
31d9779
f05e48c
984fb54
84bce94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -583,6 +589,15 @@ 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; | ||
|
||
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; | ||
|
@@ -658,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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may just need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, OK. To be clear, though, I'm pretty sure this is a bug within (possibly just the rumprun version of) NetBSD libc. The actual error is
I don't think there's any way to work around that from within our code. |
||
} | ||
|
||
mod other; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be pushed into the two lower modules as well to avoid the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. |
||
} 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! { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to avoid repeating this comment in all locations, we tend to not have a lot of comments in libc due to the large amount of duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, the trouble is that there isn't an obvious "top" or "first" place to put it. I think I'll leave it in bsd/apple/mod.rs, which is alphabetically first, and remove it from the others; does that sound good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think it's safe to just elide the comment in general. All the relevant properties of the typedef are already checked against the C representation, so it's basically never going to change, so it's ok to omit the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done.