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 | |
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.
-rw-r--r-- | src/fuchsia/mod.rs | 79 | ||||
-rw-r--r-- | src/unix/bsd/apple/mod.rs | 12 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/dragonfly/mod.rs | 4 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/mod.rs | 10 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/mod.rs | 8 | ||||
-rw-r--r-- | src/unix/bsd/mod.rs | 12 | ||||
-rw-r--r-- | src/unix/bsd/netbsdlike/netbsd/mod.rs | 34 | ||||
-rw-r--r-- | src/unix/bsd/netbsdlike/openbsd/mod.rs | 10 | ||||
-rw-r--r-- | src/unix/haiku/mod.rs | 24 | ||||
-rw-r--r-- | src/unix/hermit/mod.rs | 8 | ||||
-rw-r--r-- | src/unix/redox/mod.rs | 66 | ||||
-rw-r--r-- | src/unix/solarish/mod.rs | 23 | ||||
-rw-r--r-- | src/unix/uclibc/mod.rs | 68 | ||||
-rwxr-xr-x | src/vxworks/mod.rs | 36 |
14 files changed, 211 insertions, 183 deletions
diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index b3ff29f1e5..cd42f9a243 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3158,42 +3158,6 @@ 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 QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { - (cmd << 8) | (type_ & 0x00ff) - } - pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.bits.iter_mut() { *slot = 0; @@ -3291,6 +3255,44 @@ 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 + } + + pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + (cmd << 8) | (type_ & 0x00ff) + } +} + fn __CMSG_LEN(cmsg: *const cmsghdr) -> ::ssize_t { ((unsafe { (*cmsg).cmsg_len as ::size_t } + ::mem::size_of::<::c_long>() - 1) @@ -3302,9 +3304,8 @@ fn __CMSG_NEXT(cmsg: *const cmsghdr) -> *mut c_uchar { } fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { - unsafe { - (*mhdr).msg_control.offset((*mhdr).msg_controllen as isize) - }.cast() + unsafe { (*mhdr).msg_control.offset((*mhdr).msg_controllen as isize) } + .cast() } // EXTERN_FN diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index b6984ecd4c..1d53dee442 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3241,24 +3241,26 @@ f! { (__DARWIN_ALIGN32(::mem::size_of::<::cmsghdr>()) + length as usize) as ::c_uint } +} - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { +safe_f! { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 } - pub fn _WSTATUS(status: ::c_int) -> ::c_int { + pub {const} fn _WSTATUS(status: ::c_int) -> ::c_int { status & 0x7f } - pub fn WIFCONTINUED(status: ::c_int) -> bool { + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 } - pub fn WIFSIGNALED(status: ::c_int) -> bool { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 } - pub fn WIFSTOPPED(status: ::c_int) -> bool { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 } } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 47e3b7c152..0548a3bf4a 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1037,8 +1037,10 @@ f! { (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + _CMSG_ALIGN(length as usize)) as ::c_uint } +} - pub fn WIFSIGNALED(status: ::c_int) -> bool { +safe_f! { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 6359196138..6f3087836c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1195,15 +1195,17 @@ f! { ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps } - pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 - } - pub fn uname(buf: *mut ::utsname) -> ::c_int { __xuname(256, buf as *mut ::c_void) } } +safe_f! { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 + } +} + extern "C" { pub fn __error() -> *mut ::c_int; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index f70b8a5e6e..7bf9399d97 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1220,16 +1220,16 @@ pub const TIME_ERROR: ::c_int = 5; pub const REG_ENOSYS: ::c_int = -1; pub const REG_ILLSEQ: ::c_int = 17; -f! { - pub fn WIFCONTINUED(status: ::c_int) -> bool { +safe_f! { + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { status == 0x13 } - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 } - pub fn WIFSTOPPED(status: ::c_int) -> bool { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { (status & 0o177) == 0o177 } } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index e49703e0da..b9a0a14ef8 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -544,24 +544,26 @@ f! { *slot = 0; } } +} - pub fn WTERMSIG(status: ::c_int) -> ::c_int { +safe_f! { + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0o177 } - pub fn WIFEXITED(status: ::c_int) -> bool { + pub {const} fn WIFEXITED(status: ::c_int) -> bool { (status & 0o177) == 0 } - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { status >> 8 } - pub fn WCOREDUMP(status: ::c_int) -> bool { + pub {const} fn WCOREDUMP(status: ::c_int) -> bool { (status & 0o200) != 0 } - pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { (cmd << 8) | (type_ & 0x00ff) } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 6ddb3257e2..dfa5764ed3 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1699,18 +1699,6 @@ f! { as ::c_uint } - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - status >> 8 - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0o177) != 0o177 && (status & 0o177) != 0 - } - - pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0o177) == 0o177 - } - // dirfd() is a macro on netbsd to access // the first field of the struct where dirp points to: // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 @@ -1718,10 +1706,6 @@ f! { *(dirp as *const ::c_int) } - pub fn WIFCONTINUED(status: ::c_int) -> bool { - status == 0xffff - } - pub fn SOCKCREDSIZE(ngrps: usize) -> usize { let ngrps = if ngrps > 0 { ngrps - 1 @@ -1732,6 +1716,24 @@ f! { } } +safe_f! { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } + + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { + status == 0xffff + } +} + extern "C" { pub fn ntp_adjtime(buf: *mut timex) -> ::c_int; pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 02a1b05996..4fe134eec4 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1340,7 +1340,7 @@ fn _ALIGN(p: usize) -> usize { } f! { - pub fn WIFCONTINUED(status: ::c_int) -> bool { + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { status & 0o177777 == 0o177777 } @@ -1375,16 +1375,18 @@ f! { (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) as ::c_uint } +} - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { +safe_f! { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 } - pub fn WIFSIGNALED(status: ::c_int) -> bool { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { (status & 0o177) != 0o177 && (status & 0o177) != 0 } - pub fn WIFSTOPPED(status: ::c_int) -> bool { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { (status & 0xff) == 0o177 } } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ccd11380e7..6a0559b796 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1254,37 +1254,39 @@ f! { *slot = 0; } } +} - pub fn WIFEXITED(status: ::c_int) -> bool { +safe_f! { + pub {const} fn WIFEXITED(status: ::c_int) -> bool { (status & !0xff) == 0 } - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { status & 0xff } - pub fn WIFSIGNALED(status: ::c_int) -> bool { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { ((status >> 8) & 0xff) != 0 } - pub fn WTERMSIG(status: ::c_int) -> ::c_int { + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { (status >> 8) & 0xff } - pub fn WIFSTOPPED(status: ::c_int) -> bool { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { ((status >> 16) & 0xff) != 0 } - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { (status >> 16) & 0xff } // actually WIFCORED, but this is used everywhere else - pub fn WCOREDUMP(status: ::c_int) -> bool { + pub {const} fn WCOREDUMP(status: ::c_int) -> bool { (status & 0x10000) != 0 } - pub fn WIFCONTINUED(status: ::c_int) -> bool { + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { (status & 0x20000) != 0 } } @@ -1293,7 +1295,11 @@ extern "C" { pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; pub fn getpriority(which: ::c_int, who: id_t) -> ::c_int; - pub fn setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int; + pub fn setpriority( + which: ::c_int, + who: id_t, + priority: ::c_int, + ) -> ::c_int; pub fn utimensat( fd: ::c_int, diff --git a/src/unix/hermit/mod.rs b/src/unix/hermit/mod.rs index ae3fa22ac5..ad0fd14dcc 100644 --- a/src/unix/hermit/mod.rs +++ b/src/unix/hermit/mod.rs @@ -943,16 +943,16 @@ pub const PRIO_PROCESS: ::c_int = 0; pub const PRIO_PGRP: ::c_int = 1; pub const PRIO_USER: ::c_int = 2; -f! { - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { +safe_f! { + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { (status >> 8) & 0xff } - pub fn WIFEXITED(status: ::c_int) -> bool { + pub {const} fn WIFEXITED(status: ::c_int) -> bool { (status & 0xff) == 0 } - pub fn WTERMSIG(status: ::c_int) -> ::c_int { + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0x7f } } 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; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 9b1daeb659..ad386a3c32 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2130,36 +2130,38 @@ f! { *slot = 0; } } +} - pub fn WIFEXITED(status: ::c_int) -> bool { +safe_f! { + pub {const} fn WIFEXITED(status: ::c_int) -> bool { (status & 0xFF) == 0 } - pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { (status >> 8) & 0xFF } - pub fn WTERMSIG(status: ::c_int) -> ::c_int { + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { status & 0x7F } - pub fn WIFCONTINUED(status: ::c_int) -> bool { + pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { (status & 0xffff) == 0xffff } - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { (status & 0xff00) >> 8 } - pub fn WIFSIGNALED(status: ::c_int) -> bool { + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { ((status & 0xff) > 0) && (status & 0xff00 == 0) } - pub fn WIFSTOPPED(status: ::c_int) -> bool { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0) } - pub fn WCOREDUMP(status: ::c_int) -> bool { + pub {const} fn WCOREDUMP(status: ::c_int) -> bool { (status & 0x80) != 0 } } @@ -2415,7 +2417,7 @@ extern "C" { fd: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t, - flags: ::c_int + flags: ::c_int, ) -> ::c_int; pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; @@ -2659,7 +2661,8 @@ extern "C" { pub fn ucred_getpid(ucred: *const ucred_t) -> ::pid_t; pub fn ucred_getprojid(ucred: *const ucred_t) -> projid_t; pub fn ucred_getzoneid(ucred: *const ucred_t) -> zoneid_t; - pub fn ucred_getpflags(ucred: *const ucred_t, flags: ::c_uint) -> ::c_uint; + pub fn ucred_getpflags(ucred: *const ucred_t, flags: ::c_uint) + -> ::c_uint; pub fn ucred_size() -> ::size_t; } diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index de09587983..bcc6ebf236 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -1535,38 +1535,6 @@ 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 CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.bits.iter_mut() { *slot = 0; @@ -1598,8 +1566,42 @@ f! { pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { set1.bits == set2.bits } +} + +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 + } - pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { + pub {const} fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { (cmd << 8) | (type_ & 0x00ff) } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 2a3ac7ff78..65362e9b58 100755 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -2042,23 +2042,25 @@ extern "C" { //Dummy functions, these don't really exist in VxWorks. // wait.h macros -pub fn WIFEXITED(status: ::c_int) -> bool { - (status & 0xFF00) == 0 -} -pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0xFF00) != 0 -} -pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0xFF0000) != 0 -} -pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { - status & 0xFF -} -pub fn WTERMSIG(status: ::c_int) -> ::c_int { - (status >> 8) & 0xFF -} -pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - (status >> 16) & 0xFF +safe_f! { + pub {const} fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xFF00) == 0 + } + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0xFF00) != 0 + } + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xFF0000) != 0 + } + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { + status & 0xFF + } + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { + (status >> 8) & 0xFF + } + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { + (status >> 16) & 0xFF + } } pub fn pread( |