allocator and linux signal cleanup in platform

This commit is contained in:
auronandace
2026-02-22 08:43:20 +00:00
parent 53cc0e5aed
commit dc4542e81c
2 changed files with 30 additions and 25 deletions
+23 -18
View File
@@ -1,15 +1,20 @@
use crate::header::signal::sigval;
use core::{mem, ptr::addr_of};
use core::{
mem,
ptr::{self, addr_of},
};
use super::{
super::{PalSignal, types::*},
super::{
PalSignal,
types::{c_int, pid_t},
},
Sys, e_raw,
};
use crate::{
error::{Errno, Result},
header::{
bits_time::timespec,
signal::{SA_RESTORER, SI_QUEUE, sigaction, siginfo_t, sigset_t, stack_t},
signal::{SA_RESTORER, SI_QUEUE, sigaction, siginfo_t, sigset_t, sigval, stack_t},
sys_time::itimerval,
},
};
@@ -17,7 +22,7 @@ use crate::{
impl PalSignal for Sys {
fn getitimer(which: c_int, out: &mut itimerval) -> Result<()> {
unsafe {
e_raw(syscall!(GETITIMER, which, out as *mut _))?;
e_raw(syscall!(GETITIMER, which, ptr::from_mut(out)))?;
}
Ok(())
}
@@ -56,8 +61,8 @@ impl PalSignal for Sys {
syscall!(
SETITIMER,
which,
new as *const _,
old.map_or_else(core::ptr::null_mut, |r| r as *mut _)
ptr::from_ref(new),
old.map_or_else(ptr::null_mut, |r| ptr::from_mut(r))
)
})?;
Ok(())
@@ -81,8 +86,8 @@ impl PalSignal for Sys {
syscall!(
RT_SIGACTION,
sig,
act.as_ref().map_or_else(core::ptr::null, |x| x as *const _),
oact.map_or_else(core::ptr::null_mut, |x| x as *mut _),
act.as_ref().map_or_else(ptr::null, |x| ptr::from_ref(x)),
oact.map_or_else(ptr::null_mut, |x| ptr::from_mut(x)),
mem::size_of::<sigset_t>()
)
})
@@ -92,8 +97,8 @@ impl PalSignal for Sys {
unsafe fn sigaltstack(ss: Option<&stack_t>, old_ss: Option<&mut stack_t>) -> Result<()> {
e_raw(syscall!(
SIGALTSTACK,
ss.map_or_else(core::ptr::null, |x| x as *const _),
old_ss.map_or_else(core::ptr::null_mut, |x| x as *mut _)
ss.map_or_else(ptr::null, |x| ptr::from_ref(x)),
old_ss.map_or_else(ptr::null_mut, |x| ptr::from_mut(x))
))
.map(|_| ())
}
@@ -102,7 +107,7 @@ impl PalSignal for Sys {
e_raw(unsafe {
syscall!(
RT_SIGPENDING,
set as *mut sigset_t as usize,
ptr::from_mut::<sigset_t>(set) as usize,
mem::size_of::<sigset_t>()
)
})
@@ -114,8 +119,8 @@ impl PalSignal for Sys {
syscall!(
RT_SIGPROCMASK,
how,
set.map_or_else(core::ptr::null, |x| x as *const _),
oset.map_or_else(core::ptr::null_mut, |x| x as *mut _),
set.map_or_else(ptr::null, |x| ptr::from_ref(x)),
oset.map_or_else(ptr::null_mut, |x| ptr::from_mut(x)),
mem::size_of::<sigset_t>()
)
})
@@ -126,7 +131,7 @@ impl PalSignal for Sys {
unsafe {
e_raw(syscall!(
RT_SIGSUSPEND,
mask as *const sigset_t,
ptr::from_ref::<sigset_t>(mask),
size_of::<sigset_t>()
))
.expect_err("must fail")
@@ -141,9 +146,9 @@ impl PalSignal for Sys {
unsafe {
e_raw(syscall!(
RT_SIGTIMEDWAIT,
set as *const _,
sig.map_or_else(core::ptr::null_mut, |s| s as *mut _),
tp.map_or_else(core::ptr::null, |t| t as *const _),
ptr::from_ref(set),
sig.map_or_else(ptr::null_mut, |s| ptr::from_mut(s)),
tp.map_or_else(ptr::null, |t| ptr::from_ref(t)),
size_of::<sigset_t>()
))
.map(|s| s as c_int)