From ffbef133977555f818ccc2cbd615dcfb1d80d838 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Wed, 19 Jun 2024 12:34:20 +0200 Subject: [PATCH] Remove SignalStack, add Sigcontrol struct. --- src/data.rs | 45 +++++++++++++++------------------------------ src/lib.rs | 1 + 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/data.rs b/src/data.rs index 6ded9168ea..c201605969 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,4 +1,6 @@ +use core::cell::SyncUnsafeCell; use core::ops::{Deref, DerefMut}; +use core::sync::atomic::AtomicU64; use core::{mem, slice}; use crate::IntRegisters; use crate::flag::{EventFlags, MapFlags, PtraceFlags, SigActionFlags}; @@ -363,37 +365,7 @@ impl DerefMut for GrantDesc { } } } -#[derive(Clone, Copy, Debug, Default)] -#[repr(C, align(64))] -pub struct SignalStack { - pub intregs: IntRegisters, - pub old_procmask: u64, - pub sa_mask: u64, - pub sa_flags: u32, - pub sig_num: u32, - pub sa_handler: usize, - // offset = 3*64 bytes from this point. - // - // NOTE: If any new fields are added, make sure 64 byte alignment is maintained (for x86_64 - // XSAVE, other arches may not necessarily need that alignment). -} -impl Deref for SignalStack { - type Target = [u8]; - fn deref(&self) -> &[u8] { - unsafe { - slice::from_raw_parts(self as *const Self as *const u8, mem::size_of::()) - } - } -} - -impl DerefMut for SignalStack { - fn deref_mut(&mut self) -> &mut [u8] { - unsafe { - slice::from_raw_parts_mut(self as *mut Self as *mut u8, mem::size_of::()) - } - } -} #[derive(Clone, Copy, Debug, Default)] #[repr(C)] pub struct SetSighandlerData { @@ -418,3 +390,16 @@ impl DerefMut for SetSighandlerData { } } } + +#[derive(Debug)] +pub struct Sigcontrol { + // composed of [lo pend|lo mask, hi pend|hi mask] + pub word: [AtomicU64; 2], + + pub control: SyncUnsafeCell, + + pub saved_scratch_a: SyncUnsafeCell, + pub saved_scratch_b: SyncUnsafeCell, + pub saved_ip: SyncUnsafeCell, + pub saved_sp: SyncUnsafeCell, +} diff --git a/src/lib.rs b/src/lib.rs index 112fb1dab3..fee93e725c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(not(any(feature = "std", test)), no_std)] +#![feature(sync_unsafe_cell)] #[cfg(test)] extern crate core;