Skip to content

Commit efb23db

Browse files
committed
std: Use macros from libc instead of locally
Helps cut down on #[cfg]!
1 parent b37477c commit efb23db

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/libstd/sys/unix/process.rs

+3-24
Original file line numberDiff line numberDiff line change
@@ -519,30 +519,9 @@ impl fmt::Debug for Command {
519519
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
520520
pub struct ExitStatus(c_int);
521521

522-
#[cfg(any(target_os = "linux", target_os = "android",
523-
target_os = "nacl"))]
524-
mod status_imp {
525-
pub fn WIFEXITED(status: i32) -> bool { (status & 0xff) == 0 }
526-
pub fn WEXITSTATUS(status: i32) -> i32 { (status >> 8) & 0xff }
527-
pub fn WTERMSIG(status: i32) -> i32 { status & 0x7f }
528-
}
529-
530-
#[cfg(any(target_os = "macos",
531-
target_os = "ios",
532-
target_os = "freebsd",
533-
target_os = "dragonfly",
534-
target_os = "bitrig",
535-
target_os = "netbsd",
536-
target_os = "openbsd"))]
537-
mod status_imp {
538-
pub fn WIFEXITED(status: i32) -> bool { (status & 0x7f) == 0 }
539-
pub fn WEXITSTATUS(status: i32) -> i32 { status >> 8 }
540-
pub fn WTERMSIG(status: i32) -> i32 { status & 0o177 }
541-
}
542-
543522
impl ExitStatus {
544523
fn exited(&self) -> bool {
545-
status_imp::WIFEXITED(self.0)
524+
unsafe { libc::WIFEXITED(self.0) }
546525
}
547526

548527
pub fn success(&self) -> bool {
@@ -551,15 +530,15 @@ impl ExitStatus {
551530

552531
pub fn code(&self) -> Option<i32> {
553532
if self.exited() {
554-
Some(status_imp::WEXITSTATUS(self.0))
533+
Some(unsafe { libc::WEXITSTATUS(self.0) })
555534
} else {
556535
None
557536
}
558537
}
559538

560539
pub fn signal(&self) -> Option<i32> {
561540
if !self.exited() {
562-
Some(status_imp::WTERMSIG(self.0))
541+
Some(unsafe { libc::WTERMSIG(self.0) })
563542
} else {
564543
None
565544
}

0 commit comments

Comments
 (0)