1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

Enable signal in riscv

This commit is contained in:
Jiajie Chen 2020-06-20 17:40:51 +08:00
parent 4971713518
commit 548495a149
2 changed files with 17 additions and 25 deletions

View File

@ -25,7 +25,6 @@ pub use self::mem::*;
pub use self::misc::*;
pub use self::net::*;
pub use self::proc::*;
#[cfg(target_arch = "x86_64")]
pub use self::signal::*;
pub use self::time::*;
pub use self::user::*;
@ -38,7 +37,6 @@ mod mem;
mod misc;
mod net;
mod proc;
#[cfg(target_arch = "x86_64")]
mod signal;
mod time;
mod user;
@ -240,27 +238,22 @@ impl Syscall<'_> {
SYS_MADVISE => self.unimplemented("madvise", Ok(0)),
// signal
#[cfg(target_arch = "x86_64")]
SYS_RT_SIGACTION => self.sys_rt_sigaction(
args[0],
args[1] as *const SignalAction,
args[2] as *mut SignalAction,
args[3],
),
#[cfg(target_arch = "x86_64")]
SYS_RT_SIGRETURN => self.sys_rt_sigreturn(),
#[cfg(target_arch = "x86_64")]
SYS_RT_SIGPROCMASK => self.sys_rt_sigprocmask(
args[0],
args[1] as *const Sigset,
args[2] as *mut Sigset,
args[3],
),
#[cfg(target_arch = "x86_64")]
SYS_SIGALTSTACK => {
self.sys_sigaltstack(args[0] as *const SignalStack, args[1] as *mut SignalStack)
}
#[cfg(target_arch = "x86_64")]
SYS_KILL => self.sys_kill(args[0] as isize, args[1]),
// schedule
@ -565,23 +558,6 @@ impl Syscall<'_> {
};
Some(ret)
}
pub fn has_signal_to_do(&self) -> bool {
self.thread
.proc
.lock()
.sig_queue
.iter()
.find(|(info, tid)| {
let tid = *tid;
(tid == -1 || tid as usize == self.thread.tid)
&& !self
.thread
.sig_mask
.contains(FromPrimitive::from_i32(info.signo).unwrap())
})
.is_some()
}
}
pub type SysResult = Result<usize, SysError>;

View File

@ -5,6 +5,22 @@ use crate::syscall::{SysResult, Syscall};
use num::FromPrimitive;
impl Syscall<'_> {
pub fn has_signal_to_do(&self) -> bool {
self.thread
.proc
.lock()
.sig_queue
.iter()
.find(|(info, tid)| {
let tid = *tid;
(tid == -1 || tid as usize == self.thread.tid)
&& !self
.thread
.sig_mask
.contains(FromPrimitive::from_i32(info.signo).unwrap())
})
.is_some()
}
pub fn sys_rt_sigaction(
&self,
signum: usize,
@ -83,7 +99,7 @@ impl Syscall<'_> {
self.tf.general.rsp = mc.rsp;
*/
let ret = self.context.general.rax as isize;
let ret = self.context.get_syscall_ret() as isize;
if ret >= 0 {
Ok(ret as usize)
} else {