mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 10:53:25 +00:00
Fix panic in futex and rt_sigprocmask
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
364ef48e2f
commit
4c1f6a4e32
@ -19,7 +19,7 @@ pub fn sys_futex(
|
||||
ctx: &Context,
|
||||
) -> Result<SyscallReturn> {
|
||||
// FIXME: we current ignore futex flags
|
||||
let (futex_op, futex_flags) = futex_op_and_flags_from_u32(futex_op as _).unwrap();
|
||||
let (futex_op, futex_flags) = futex_op_and_flags_from_u32(futex_op as _)?;
|
||||
debug!(
|
||||
"futex_op = {:?}, futex_flags = {:?}, futex_addr = 0x{:x}",
|
||||
futex_op, futex_flags, futex_addr
|
||||
@ -42,24 +42,24 @@ pub fn sys_futex(
|
||||
|
||||
let res = match futex_op {
|
||||
FutexOp::FUTEX_WAIT => {
|
||||
let timeout = get_futex_timeout(utime_addr).expect("Invalid time addr");
|
||||
let timeout = get_futex_timeout(utime_addr)?;
|
||||
futex_wait(futex_addr as _, futex_val as _, &timeout).map(|_| 0)
|
||||
}
|
||||
FutexOp::FUTEX_WAIT_BITSET => {
|
||||
let timeout = get_futex_timeout(utime_addr).expect("Invalid time addr");
|
||||
let timeout = get_futex_timeout(utime_addr)?;
|
||||
futex_wait_bitset(futex_addr as _, futex_val as _, &timeout, bitset as _).map(|_| 0)
|
||||
}
|
||||
FutexOp::FUTEX_WAKE => {
|
||||
let max_count = get_futex_val(futex_val as i32).expect("Invalid futex val");
|
||||
let max_count = get_futex_val(futex_val as i32)?;
|
||||
futex_wake(futex_addr as _, max_count).map(|count| count as isize)
|
||||
}
|
||||
FutexOp::FUTEX_WAKE_BITSET => {
|
||||
let max_count = get_futex_val(futex_val as i32).expect("Invalid futex val");
|
||||
let max_count = get_futex_val(futex_val as i32)?;
|
||||
futex_wake_bitset(futex_addr as _, max_count, bitset as _).map(|count| count as isize)
|
||||
}
|
||||
FutexOp::FUTEX_REQUEUE => {
|
||||
let max_nwakes = get_futex_val(futex_val as i32).expect("Invalid futex val");
|
||||
let max_nrequeues = get_futex_val(utime_addr as i32).expect("Invalid utime addr");
|
||||
let max_nwakes = get_futex_val(futex_val as i32)?;
|
||||
let max_nrequeues = get_futex_val(utime_addr as i32)?;
|
||||
futex_requeue(
|
||||
futex_addr as _,
|
||||
max_nwakes,
|
||||
|
@ -26,7 +26,7 @@ pub fn sys_rt_sigprocmask(
|
||||
if sigset_size != 8 {
|
||||
error!("sigset size is not equal to 8");
|
||||
}
|
||||
do_rt_sigprocmask(mask_op, set_ptr, oldset_ptr, ctx).unwrap();
|
||||
do_rt_sigprocmask(mask_op, set_ptr, oldset_ptr, ctx)?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user