Remove unused defs, add 'inhibit' sigcontrol flag.
This commit is contained in:
+2
-2
@@ -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<usize> {
|
||||
|
||||
+3
-38
@@ -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<extern "C" fn(usize)>,
|
||||
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::<SigAction>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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::<SigAction>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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<extern "C" fn(usize)> which will mean 0
|
||||
// becomes None
|
||||
let _ = mem::transmute::<Option<extern "C" fn(usize)>, 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<usize>,
|
||||
pub control_flags: SyncUnsafeCell<SigcontrolFlags>,
|
||||
|
||||
pub saved_scratch_a: SyncUnsafeCell<usize>,
|
||||
pub saved_scratch_b: SyncUnsafeCell<usize>,
|
||||
|
||||
+8
-20
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user