-
Notifications
You must be signed in to change notification settings - Fork 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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9d1e484
Add waitid and related constants and types.
zackw 644929a
Corrections based on CI failures.
zackw f1a91da
Another round of portability fixes:
zackw 31d9779
Reorganize again; more portability fixes.
zackw f05e48c
Patch in id_t missing in a few places
zackw 984fb54
Changes requested by reviewers
zackw 84bce94
Remove remaining copy of the comment about idtype_t being an enum.
zackw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,20 @@ 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, | ||
|
@@ -203,6 +217,22 @@ 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")] { | ||
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. Similar to above, could this |
||
// 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 | ||
|
@@ -447,6 +477,11 @@ 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) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Instead of a
cfg_if!
block here, could the definition of this just get pushed down into respective modules?