From 0aaa7264db967c9e8572265637fcf6660578a6e2 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 29 Dec 2018 08:20:27 -0700 Subject: [PATCH] Fix signal support --- src/header/signal/linux.rs | 1 + src/header/signal/mod.rs | 1 - src/header/signal/redox.rs | 1 + src/header/sys_time/mod.rs | 18 ------------------ src/platform/redox/signal.rs | 12 ++++++------ 5 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/header/signal/linux.rs b/src/header/signal/linux.rs index d056b105f9..cfa63b5563 100644 --- a/src/header/signal/linux.rs +++ b/src/header/signal/linux.rs @@ -54,6 +54,7 @@ pub const SIGPOLL: usize = SIGIO; pub const SIGPWR: usize = 30; pub const SIGSYS: usize = 31; pub const SIGUNUSED: usize = SIGSYS; +pub const NSIG: usize = 32; pub const SA_NOCLDSTOP: usize = 1; pub const SA_NOCLDWAIT: usize = 2; diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index 04200a0396..8bb133bb01 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -36,7 +36,6 @@ pub struct sigaction { pub sa_mask: sigset_t, } -pub const NSIG: usize = 64; pub type sigset_t = c_ulong; #[no_mangle] diff --git a/src/header/signal/redox.rs b/src/header/signal/redox.rs index 331997d1db..e13787ee86 100644 --- a/src/header/signal/redox.rs +++ b/src/header/signal/redox.rs @@ -51,6 +51,7 @@ pub const SIGWINCH: usize = 28; pub const SIGIO: usize = 29; pub const SIGPWR: usize = 30; pub const SIGSYS: usize = 31; +pub const NSIG: usize = 32; pub const SA_NOCLDSTOP: usize = 0x00000001; pub const SA_NOCLDWAIT: usize = 0x00000002; diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index a57a967561..c961a7a42c 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -53,17 +53,6 @@ pub extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int { Sys::gettimeofday(tp, tzp) } -// #[no_mangle] -pub extern "C" fn select( - nfds: c_int, - readfds: *mut fd_set, - writefds: *mut fd_set, - errorfds: *mut fd_set, - timeout: *mut timeval, -) -> c_int { - unimplemented!(); -} - #[no_mangle] pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c_int { let path = CStr::from_ptr(path); @@ -79,10 +68,3 @@ pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c ]; Sys::utimens(path, times_spec.as_ptr()) } - -/* -#[no_mangle] -pub extern "C" fn func(args) -> c_int { - unimplemented!(); -} -*/ diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index d070ff2492..1779505d1c 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -7,7 +7,7 @@ use super::super::{Pal, PalSignal}; use super::{e, Sys}; use header::errno::EINVAL; use header::signal::{sigaction, sigset_t}; -use header::sys_time::itimerval; +use header::sys_time::{ITIMER_REAL, itimerval}; impl PalSignal for Sys { fn getitimer(which: c_int, out: *mut itimerval) -> c_int { @@ -20,7 +20,7 @@ impl PalSignal for Sys { }; let fd = e(syscall::open(path, syscall::O_RDONLY | syscall::O_CLOEXEC)); - if fd < 0 { + if fd == !0 { return -1; } @@ -29,7 +29,7 @@ impl PalSignal for Sys { let _ = syscall::close(fd); - if count < 0 { + if count == !0 { return -1; } @@ -65,7 +65,7 @@ impl PalSignal for Sys { }; let fd = e(syscall::open(path, syscall::O_RDWR | syscall::O_CLOEXEC)); - if fd < 0 { + if fd == !0 { return -1; } @@ -73,7 +73,7 @@ impl PalSignal for Sys { let mut count = e(syscall::read(fd, &mut spec)); - if count >= 0 { + if count != !0 { unsafe { if ! old.is_null() { (*old).it_interval.tv_sec = spec.it_interval.tv_sec; @@ -93,7 +93,7 @@ impl PalSignal for Sys { let _ = syscall::close(fd); - if count < 0 { + if count == !0 { return -1; }