From 2f944328e5b594a351a1ff0c51a005229bb52df9 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Wed, 19 Jun 2024 12:52:56 +0200 Subject: [PATCH] Remove unused defs, add 'inhibit' sigcontrol flag. --- src/call.rs | 4 ++-- src/data.rs | 41 +++-------------------------------------- src/flag.rs | 28 ++++++++-------------------- 3 files changed, 13 insertions(+), 60 deletions(-) diff --git a/src/call.rs b/src/call.rs index 75fdc194f1..4710c70bd0 100644 --- a/src/call.rs +++ b/src/call.rs @@ -1,10 +1,10 @@ use super::arch::*; -use super::data::{Map, SigAction, Stat, StatVfs, TimeSpec}; +use super::data::{Map, Stat, StatVfs, TimeSpec}; use super::error::Result; use super::flag::*; use super::number::*; -use core::{mem, ptr}; +use core::mem; /// Close a file pub fn close(fd: usize) -> Result { diff --git a/src/data.rs b/src/data.rs index c201605969..cd5c586022 100644 --- a/src/data.rs +++ b/src/data.rs @@ -2,8 +2,8 @@ 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}; + +use crate::flag::{EventFlags, MapFlags, PtraceFlags, SigcontrolFlags}; #[derive(Copy, Clone, Debug, Default)] #[repr(C)] @@ -145,41 +145,6 @@ impl DerefMut for Packet { } } -#[derive(Copy, Clone, Debug, Default, PartialEq)] -#[repr(C)] -pub struct SigAction { - pub sa_handler: Option, - pub sa_mask: u64, - pub sa_flags: SigActionFlags, -} -impl Deref for SigAction { - type Target = [u8]; - fn deref(&self) -> &[u8] { - unsafe { - slice::from_raw_parts(self as *const SigAction as *const u8, - mem::size_of::()) - } - } -} - -impl DerefMut for SigAction { - fn deref_mut(&mut self) -> &mut [u8] { - unsafe { - slice::from_raw_parts_mut(self as *mut SigAction as *mut u8, - mem::size_of::()) - } - } -} - -#[allow(dead_code)] -unsafe fn _assert_size_of_function_is_sane() { - // Transmuting will complain *at compile time* if sizes differ. - // Rust forbids a fn-pointer from being 0 so to allow SIG_DFL to - // exist, we use Option which will mean 0 - // becomes None - let _ = mem::transmute::, usize>(None); -} - #[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct Stat { @@ -396,7 +361,7 @@ pub struct Sigcontrol { // composed of [lo pend|lo mask, hi pend|hi mask] pub word: [AtomicU64; 2], - pub control: SyncUnsafeCell, + pub control_flags: SyncUnsafeCell, pub saved_scratch_a: SyncUnsafeCell, pub saved_scratch_b: SyncUnsafeCell, diff --git a/src/flag.rs b/src/flag.rs index 16cf104829..13f62e2103 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -257,26 +257,6 @@ pub const SIGIO: usize = 29; pub const SIGPWR: usize = 30; pub const SIGSYS: usize = 31; -pub const SIG_DFL: usize = 0; -pub const SIG_IGN: usize = 1; - -pub const SIG_BLOCK: usize = 0; -pub const SIG_UNBLOCK: usize = 1; -pub const SIG_SETMASK: usize = 2; - -bitflags! { - pub struct SigActionFlags: usize { - const SA_NOCLDSTOP = 0x00000001; - const SA_NOCLDWAIT = 0x00000002; - const SA_SIGINFO = 0x00000004; - const SA_RESTORER = 0x04000000; - const SA_ONSTACK = 0x08000000; - const SA_RESTART = 0x10000000; - const SA_NODEFER = 0x40000000; - const SA_RESETHAND = 0x80000000; - } -} - bitflags! { pub struct WaitFlags: usize { const WNOHANG = 0x01; @@ -345,3 +325,11 @@ bitflags! { // TODO: O_DIRECT? } } +bitflags! { + pub struct SigcontrolFlags: usize { + /// Prevents the kernel from jumping the context to the signal trampoline, but otherwise + /// has absolutely no effect on which signals are blocked etc. Meant to be used for + /// short-lived critical sections inside libc. + const INHIBIT_DELIVERY = 1; + } +}