Skip to content
Snippets Groups Projects
Verified Commit 8298417d authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Implement sigpending on Redox.

parent c639fd37
No related branches found
No related tags found
1 merge request!480Refactor redox runtime and impl signals in userspace
...@@ -497,3 +497,12 @@ pub unsafe fn sigaltstack(new: Option<&Sigaltstack>, old_out: Option<&mut Sigalt ...@@ -497,3 +497,12 @@ pub unsafe fn sigaltstack(new: Option<&Sigaltstack>, old_out: Option<&mut Sigalt
} }
pub const MIN_SIGALTSTACK_SIZE: usize = 8192; pub const MIN_SIGALTSTACK_SIZE: usize = 8192;
pub fn currently_pending() -> u64 {
let control = &unsafe { Tcb::current().unwrap() }.os_specific.control;
let w0 = control.word[0].load(Ordering::Relaxed);
let w1 = control.word[0].load(Ordering::Relaxed);
let pending_blocked_lo = w0 & !(w0 >> 32);
let pending_unblocked_hi = w1 & !(w0 >> 32);
pending_blocked_lo | (pending_unblocked_hi << 32)
}
...@@ -7,11 +7,13 @@ use cbitset::BitSet; ...@@ -7,11 +7,13 @@ use cbitset::BitSet;
use crate::{ use crate::{
header::{errno, time::timespec}, header::{errno, time::timespec},
platform::{self, types::*, Pal, PalSignal, Sys}, platform::{self, types::*, Pal, PalSignal, Sys},
pthread::{self, ResultExt}, pthread::{self, Errno, ResultExt},
}; };
pub use self::sys::*; pub use self::sys::*;
use super::errno::EFAULT;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[path = "linux.rs"] #[path = "linux.rs"]
pub mod sys; pub mod sys;
...@@ -241,7 +243,9 @@ pub unsafe extern "C" fn sigpause(sig: c_int) -> c_int { ...@@ -241,7 +243,9 @@ pub unsafe extern "C" fn sigpause(sig: c_int) -> c_int {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sigpending(set: *mut sigset_t) -> c_int { pub unsafe extern "C" fn sigpending(set: *mut sigset_t) -> c_int {
Sys::sigpending(set) (|| Sys::sigpending(set.as_mut().ok_or(Errno(EFAULT))?))()
.map(|()| 0)
.or_minus_one_errno()
} }
const BELOW_SIGRTMIN_MASK: sigset_t = (1 << SIGRTMIN) - 1; const BELOW_SIGRTMIN_MASK: sigset_t = (1 << SIGRTMIN) - 1;
......
...@@ -74,8 +74,15 @@ impl PalSignal for Sys { ...@@ -74,8 +74,15 @@ impl PalSignal for Sys {
.map(|_| ()) .map(|_| ())
} }
unsafe fn sigpending(set: *mut sigset_t) -> c_int { fn sigpending(set: &mut sigset_t) -> Result<(), Errno> {
e(syscall!(RT_SIGPENDING, set, NSIG / 8)) as c_int e_raw(unsafe {
syscall!(
RT_SIGPENDING,
set as *mut sigset_t as usize,
mem::size_of::<sigset_t>()
)
})
.map(|_| ())
} }
fn sigprocmask( fn sigprocmask(
......
...@@ -27,7 +27,7 @@ pub trait PalSignal: Pal { ...@@ -27,7 +27,7 @@ pub trait PalSignal: Pal {
unsafe fn sigaltstack(ss: Option<&stack_t>, old_ss: Option<&mut stack_t>) -> Result<(), Errno>; unsafe fn sigaltstack(ss: Option<&stack_t>, old_ss: Option<&mut stack_t>) -> Result<(), Errno>;
unsafe fn sigpending(set: *mut sigset_t) -> c_int; fn sigpending(set: &mut sigset_t) -> Result<(), Errno>;
fn sigprocmask( fn sigprocmask(
how: c_int, how: c_int,
......
...@@ -223,9 +223,9 @@ impl PalSignal for Sys { ...@@ -223,9 +223,9 @@ impl PalSignal for Sys {
Ok(()) Ok(())
} }
unsafe fn sigpending(set: *mut sigset_t) -> c_int { fn sigpending(set: &mut sigset_t) -> Result<(), Errno> {
ERRNO.set(ENOSYS); *set = redox_rt::signal::currently_pending();
-1 Ok(())
} }
fn sigprocmask( fn sigprocmask(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment