diff options
author | Daniil Bondarev <xonatius@gmail.com> | 2020-09-12 23:15:38 -0700 |
---|---|---|
committer | Daniil Bondarev <xonatius@gmail.com> | 2020-09-12 23:38:06 -0700 |
commit | 773f5562ba04ad8b7ba772e99645922ea908be76 (patch) | |
tree | 3a7ce4ee9cdf67822733c196f78a04f5959e15fc /src/unix/redox | |
parent | c2a184b255c2d7548e17b66f19f0330192ce6484 (diff) | |
download | rust-libc-773f5562ba04ad8b7ba772e99645922ea908be76.tar.gz |
Use safe_f! consistently across platforms
The pr #1870 introduced safe_f! macro, which made some functions like
WIFEXITED and WEXITSTATUS const and safe on linux_like platform only,
which causes inconsistency when trying to use those functions in crates
compiled across multiple platforms, as using unsafe on those functions
will generate unused_unsafe warning on linux platforms and lack of
unsafe block will fail compilation on non-linux platforms.
To avoid the inconsistency, this commit applies the same macro for all
the same functions on other platforms too.
Diffstat (limited to 'src/unix/redox')
-rw-r--r-- | src/unix/redox/mod.rs | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 55f64ee54f..6025be31b2 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -829,38 +829,6 @@ pub const PRIO_USER: ::c_int = 2; // wait.h f! { - pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0xff) == 0x7f - } - - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - (status >> 8) & 0xff - } - - pub fn WIFCONTINUED(status: ::c_int) -> bool { - status == 0xffff - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - ((status & 0x7f) + 1) as i8 >= 2 - } - - pub fn WTERMSIG(status: ::c_int) -> ::c_int { - status & 0x7f - } - - pub fn WIFEXITED(status: ::c_int) -> bool { - (status & 0x7f) == 0 - } - - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { - (status >> 8) & 0xff - } - - pub fn WCOREDUMP(status: ::c_int) -> bool { - (status & 0x80) != 0 - } - pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { let fd = fd as usize; let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8; @@ -888,6 +856,40 @@ f! { } } +safe_f! { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } + + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub {const} fn WIFEXITED(status: ::c_int) -> bool { + (status & 0x7f) == 0 + } + + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + pub {const} fn WCOREDUMP(status: ::c_int) -> bool { + (status & 0x80) != 0 + } +} + extern "C" { // errno.h pub fn __errno_location() -> *mut ::c_int; |