diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-02-09 15:13:33 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-02-10 09:28:49 -0800 |
| commit | efb23db79a5cc16770a7c3d5cef7059d868dea8f (patch) | |
| tree | bd3281d7d1082d6b39defcfc24c875e7624cb09b /src/libstd | |
| parent | b37477c03e7683cc67273ddc5506496a7b03971c (diff) | |
| download | rust-efb23db79a5cc16770a7c3d5cef7059d868dea8f.tar.gz rust-efb23db79a5cc16770a7c3d5cef7059d868dea8f.zip | |
std: Use macros from libc instead of locally
Helps cut down on #[cfg]!
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/sys/unix/process.rs | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index 60785f37642..9e12b2f116c 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -519,30 +519,9 @@ impl fmt::Debug for Command { #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub struct ExitStatus(c_int); -#[cfg(any(target_os = "linux", target_os = "android", - target_os = "nacl"))] -mod status_imp { - pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 } - pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff } - pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f } -} - -#[cfg(any(target_os = "macos", - target_os = "ios", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] -mod status_imp { - pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 } - pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 } - pub fn WTERMSIG(status: i32) -> i32 { status & 0o177 } -} - impl ExitStatus { fn exited(&self) -> bool { - status_imp::WIFEXITED(self.0) + unsafe { libc::WIFEXITED(self.0) } } pub fn success(&self) -> bool { @@ -551,7 +530,7 @@ impl ExitStatus { pub fn code(&self) -> Option<i32> { if self.exited() { - Some(status_imp::WEXITSTATUS(self.0)) + Some(unsafe { libc::WEXITSTATUS(self.0) }) } else { None } @@ -559,7 +538,7 @@ impl ExitStatus { pub fn signal(&self) -> Option<i32> { if !self.exited() { - Some(status_imp::WTERMSIG(self.0)) + Some(unsafe { libc::WTERMSIG(self.0) }) } else { None } |
