Unverified Commit 64c117af authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub
Browse files

Merge pull request #22 from jD91mZM2/wifstuff

Add wif* functions
parents 8f012900 e145ba3e
......@@ -349,3 +349,29 @@ pub fn write(fd: usize, buf: &[u8]) -> Result<usize> {
pub fn sched_yield() -> Result<usize> {
unsafe { syscall0(SYS_YIELD) }
}
/// If wifsignaled(status), the terminating signal.
#[inline(always)]
pub fn wtermsig(status: usize) -> usize {
status & 0x7f
}
/// True if status indicates normal termination.
#[inline(always)]
pub fn wifexited(status: usize) -> bool {
wtermsig(status) == 0
}
/// True if status indicates the child is stopped.
#[inline(always)]
pub fn wifstopped(status: usize) -> bool {
(status & 0xff) == 0x7f
}
/// True if status indicates the child continued after a stop.
#[inline(always)]
pub fn wifcontinued(status: usize) -> bool {
status == 0xffff
}
/// True if STATUS indicates termination by a signal.
#[inline(always)]
pub fn wifsignaled(status: usize) -> bool {
((status & 0x7f) + 1) as i8 >= 2
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment