Merge branch 'unify-signal-constants' into 'master'
unify and document most of the signal constants See merge request redox-os/relibc!1480
This commit is contained in:
@@ -0,0 +1,216 @@
|
||||
// These constants have the same values on Redox and Linux.
|
||||
|
||||
// Default actions are:
|
||||
// - T (Abnormal termination of the process)
|
||||
// - A (Abnormal termination of the process with additional actions)
|
||||
// - I (Ignore the signal)
|
||||
// - S (Stop the process)
|
||||
// - C (Continue the process, if it is stopped; otherwise, ignore the signal)
|
||||
|
||||
/// Hangup.
|
||||
/// Default action: T
|
||||
pub const SIGHUP: usize = 1;
|
||||
/// Terminal interrupt signal.
|
||||
/// Default action: T
|
||||
pub const SIGINT: usize = 2;
|
||||
/// Terminal quit signal.
|
||||
/// Default action: A
|
||||
pub const SIGQUIT: usize = 3;
|
||||
/// Illegal instruction.
|
||||
/// Default action: A
|
||||
pub const SIGILL: usize = 4;
|
||||
/// Trace/Breakpoint trap.
|
||||
/// Default action: A
|
||||
pub const SIGTRAP: usize = 5;
|
||||
/// Process abort signal.
|
||||
/// Default action: A
|
||||
pub const SIGABRT: usize = 6;
|
||||
/// Access to an undefined portion of a memory object.
|
||||
/// Default action: A
|
||||
pub const SIGBUS: usize = 7;
|
||||
/// Erroneous arithmetic operation.
|
||||
/// Default action: A
|
||||
pub const SIGFPE: usize = 8;
|
||||
/// Kill (cannot be caught or ignored).
|
||||
/// Default action: T
|
||||
pub const SIGKILL: usize = 9;
|
||||
/// User-defined signal 1.
|
||||
/// Default action: T
|
||||
pub const SIGUSR1: usize = 10;
|
||||
/// Invalid memory reference.
|
||||
/// Default action: A
|
||||
pub const SIGSEGV: usize = 11;
|
||||
/// User-defined signal 2.
|
||||
/// Default action: T
|
||||
pub const SIGUSR2: usize = 12;
|
||||
/// Write on a pipe with no one to read it.
|
||||
/// Default action: T
|
||||
pub const SIGPIPE: usize = 13;
|
||||
/// Alarm clock.
|
||||
/// Default action: T
|
||||
pub const SIGALRM: usize = 14;
|
||||
/// Termination signal.
|
||||
/// Default action: T
|
||||
pub const SIGTERM: usize = 15;
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
|
||||
///
|
||||
/// Stack fault on coprocessor (unused).
|
||||
pub const SIGSTKFLT: usize = 16;
|
||||
/// Child process terminated, stopped or continued.
|
||||
/// Default action: I
|
||||
pub const SIGCHLD: usize = 17;
|
||||
/// Continue executing, if stopped.
|
||||
/// Default action: C
|
||||
pub const SIGCONT: usize = 18;
|
||||
/// Stop executing (cannot be caught or ignored).
|
||||
/// Default action: S
|
||||
pub const SIGSTOP: usize = 19;
|
||||
/// Terminal stop signal.
|
||||
/// Default action: S
|
||||
pub const SIGTSTP: usize = 20;
|
||||
/// Background process attempting read.
|
||||
/// Default action: S
|
||||
pub const SIGTTIN: usize = 21;
|
||||
/// Background process attempting write.
|
||||
/// Default action: S
|
||||
pub const SIGTTOU: usize = 22;
|
||||
/// High bandwidth data is available at a socket.
|
||||
/// Default action: I
|
||||
pub const SIGURG: usize = 23;
|
||||
/// CPU time limit exceeded.
|
||||
/// Default action: A
|
||||
pub const SIGXCPU: usize = 24;
|
||||
/// File size limit exceeded.
|
||||
/// Default action: A
|
||||
pub const SIGXFSZ: usize = 25;
|
||||
/// Virtual timer expired.
|
||||
/// Default action: T
|
||||
pub const SIGVTALRM: usize = 26;
|
||||
// TODO mark #[deprecated]?
|
||||
/// Obsolete in issue 7, removed in issue 8.
|
||||
///
|
||||
/// Profiling timer expired.
|
||||
/// Default action: T
|
||||
pub const SIGPROF: usize = 27;
|
||||
/// Terminal window size changed.
|
||||
/// Default action: I
|
||||
pub const SIGWINCH: usize = 28;
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
|
||||
///
|
||||
/// I/O now possible (4.2BSD).
|
||||
pub const SIGIO: usize = 29;
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
|
||||
///
|
||||
/// Power failure (System V).
|
||||
pub const SIGPWR: usize = 30;
|
||||
/// Bad system call.
|
||||
/// Default action: A
|
||||
pub const SIGSYS: usize = 31;
|
||||
// TODO add `NSIG_MAX` to limits.h and `_SC_NSIG` to unistd.h sysconf
|
||||
/// Non-POSIX.
|
||||
///
|
||||
/// Intended to define the maximum number of signals supported by this
|
||||
/// implemenatation.
|
||||
///
|
||||
/// POSIX added `NSIG_MAX` as a portable replacement based on the size of the
|
||||
/// `sigset_t` type.
|
||||
pub const NSIG: usize = 32;
|
||||
|
||||
/// Lower bound (inclusive) of the range of signal numbers reserved for
|
||||
/// application use and for realtime signals.
|
||||
pub const SIGRTMIN: usize = 35; // TODO: decrease to 34
|
||||
/// Upper bound (inclusive) of the range of signal numbers reserved for
|
||||
/// application use and for realtime signals.
|
||||
pub const SIGRTMAX: usize = 64;
|
||||
|
||||
/// Causes implementations not to create zombie processes or status information
|
||||
/// on child termination. See `sigaction()`.
|
||||
pub const SA_NOCLDWAIT: usize = 2;
|
||||
|
||||
/// Process is executing on an alternate signal stack.
|
||||
pub const SS_ONSTACK: usize = 1;
|
||||
/// Alternate signal stack is disabled.
|
||||
pub const SS_DISABLE: usize = 2;
|
||||
|
||||
// Redox note: should include both SigStack size, and some extra room for the libc handler
|
||||
// Linux note: Those two should be updated from kernel headers
|
||||
/// Minimum stack size for a signal handler.
|
||||
pub const MINSIGSTKSZ: usize = 2048;
|
||||
/// Default size in bytes for the alternate signal stack.
|
||||
pub const SIGSTKSZ: usize = 8096;
|
||||
|
||||
/// Signal sent by `sigqueue()`.
|
||||
pub const SI_QUEUE: i32 = -1;
|
||||
/// Signal sent by `kill()`.
|
||||
pub const SI_USER: i32 = 0;
|
||||
/// Signal generated by expiration of a timer set by `timer_settime()`.
|
||||
pub const SI_TIMER: i32 = 1;
|
||||
/// Signal generated by completion of an asynchronous I/O request.
|
||||
pub const SI_ASYNCIO: i32 = 2;
|
||||
/// Signal generated by arrival of a message on an empty message queue.
|
||||
pub const SI_MESGQ: i32 = 3;
|
||||
|
||||
// si_code values (signal-specific)
|
||||
/// Illegal opcode.
|
||||
pub const ILL_ILLOPC: i32 = 1;
|
||||
/// Illegal operand.
|
||||
pub const ILL_ILLOPN: i32 = 2;
|
||||
/// Illegal addressing mode.
|
||||
pub const ILL_ILLADR: i32 = 3;
|
||||
/// Illegal trap.
|
||||
pub const ILL_ILLTRP: i32 = 4;
|
||||
/// Privileged opcode.
|
||||
pub const ILL_PRVOPC: i32 = 5;
|
||||
/// Privileged register.
|
||||
pub const ILL_PRVREG: i32 = 6;
|
||||
/// Coprocessor error.
|
||||
pub const ILL_COPROC: i32 = 7;
|
||||
/// Internal stack error.
|
||||
pub const ILL_BADSTK: i32 = 8;
|
||||
|
||||
/// Integer divide by zero.
|
||||
pub const FPE_INTDIV: i32 = 1;
|
||||
/// Integer overflow.
|
||||
pub const FPE_INTOVF: i32 = 2;
|
||||
/// Floating-point divide by zero.
|
||||
pub const FPE_FLTDIV: i32 = 3;
|
||||
/// Floating-point overflow.
|
||||
pub const FPE_FLTOVF: i32 = 4;
|
||||
/// Floating-point underflow.
|
||||
pub const FPE_FLTUND: i32 = 5;
|
||||
/// Floating-point inexact result.
|
||||
pub const FPE_FLTRES: i32 = 6;
|
||||
/// Invalid floating-point operation.
|
||||
pub const FPE_FLTINV: i32 = 7;
|
||||
/// Subscript out of range.
|
||||
pub const FPE_FLTSUB: i32 = 8;
|
||||
|
||||
/// Address not mapped to object.
|
||||
pub const SEGV_MAPERR: i32 = 1;
|
||||
/// Invalid permissions for mapped object.
|
||||
pub const SEGV_ACCERR: i32 = 2;
|
||||
|
||||
/// Invalid address alignment.
|
||||
pub const BUS_ADRALN: i32 = 1;
|
||||
/// Nonexistent physical address.
|
||||
pub const BUS_ADRERR: i32 = 2;
|
||||
/// Object-specific hardware error.
|
||||
pub const BUS_OBJERR: i32 = 3;
|
||||
|
||||
/// Process breakpoint.
|
||||
pub const TRAP_BRKPT: i32 = 1;
|
||||
/// Process trace trap.
|
||||
pub const TRAP_TRACE: i32 = 2;
|
||||
|
||||
/// Child has exited.
|
||||
pub const CLD_EXITED: i32 = 1;
|
||||
/// Child has terminated abnormally with no additional actions.
|
||||
pub const CLD_KILLED: i32 = 2;
|
||||
/// Child has terminated abnormally and additional actions may have been taken.
|
||||
pub const CLD_DUMPED: i32 = 3;
|
||||
/// Traced child has trapped.
|
||||
pub const CLD_TRAPPED: i32 = 4;
|
||||
/// Child has stopped.
|
||||
pub const CLD_STOPPED: i32 = 5;
|
||||
/// Stopped child has continued.
|
||||
pub const CLD_CONTINUED: i32 = 6;
|
||||
+15
-88
@@ -34,47 +34,23 @@ global_asm!(
|
||||
"
|
||||
);
|
||||
|
||||
pub const SIGHUP: usize = 1;
|
||||
pub const SIGINT: usize = 2;
|
||||
pub const SIGQUIT: usize = 3;
|
||||
pub const SIGILL: usize = 4;
|
||||
pub const SIGTRAP: usize = 5;
|
||||
pub const SIGABRT: usize = 6;
|
||||
pub const SIGIOT: usize = SIGABRT;
|
||||
pub const SIGBUS: usize = 7;
|
||||
pub const SIGFPE: usize = 8;
|
||||
pub const SIGKILL: usize = 9;
|
||||
pub const SIGUSR1: usize = 10;
|
||||
pub const SIGSEGV: usize = 11;
|
||||
pub const SIGUSR2: usize = 12;
|
||||
pub const SIGPIPE: usize = 13;
|
||||
pub const SIGALRM: usize = 14;
|
||||
pub const SIGTERM: usize = 15;
|
||||
pub const SIGSTKFLT: usize = 16;
|
||||
pub const SIGCHLD: usize = 17;
|
||||
pub const SIGCONT: usize = 18;
|
||||
pub const SIGSTOP: usize = 19;
|
||||
pub const SIGTSTP: usize = 20;
|
||||
pub const SIGTTIN: usize = 21;
|
||||
pub const SIGTTOU: usize = 22;
|
||||
pub const SIGURG: usize = 23;
|
||||
pub const SIGXCPU: usize = 24;
|
||||
pub const SIGXFSZ: usize = 25;
|
||||
pub const SIGVTALRM: usize = 26;
|
||||
pub const SIGPROF: usize = 27;
|
||||
pub const SIGWINCH: usize = 28;
|
||||
pub const SIGIO: usize = 29;
|
||||
pub const SIGPOLL: usize = SIGIO;
|
||||
pub const SIGPWR: usize = 30;
|
||||
pub const SIGSYS: usize = 31;
|
||||
pub const SIGUNUSED: usize = SIGSYS;
|
||||
pub const NSIG: usize = 32;
|
||||
|
||||
pub const SIGRTMIN: usize = 35; // TODO: decrease to 34
|
||||
pub const SIGRTMAX: usize = 64;
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
|
||||
///
|
||||
/// IOT trap. A synonym for `SIGABRT`.
|
||||
pub const SIGIOT: usize = super::constants::SIGABRT;
|
||||
// TODO mark #[deprecated]?
|
||||
/// Obsolete in issue 7, removed in issue 8.
|
||||
///
|
||||
/// Pollable event.
|
||||
/// Default action: T
|
||||
pub const SIGPOLL: usize = super::constants::SIGIO;
|
||||
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/signal.7.html>.
|
||||
///
|
||||
/// Synonymous with `SIGSYS`.
|
||||
pub const SIGUNUSED: usize = super::constants::SIGSYS;
|
||||
|
||||
// TODO why are these SA_* constants different to Redox?
|
||||
pub const SA_NOCLDSTOP: usize = 1;
|
||||
pub const SA_NOCLDWAIT: usize = 2;
|
||||
pub const SA_SIGINFO: usize = 4;
|
||||
pub const SA_ONSTACK: usize = 0x0800_0000;
|
||||
pub const SA_RESTART: usize = 0x1000_0000;
|
||||
@@ -82,55 +58,6 @@ pub const SA_NODEFER: usize = 0x4000_0000;
|
||||
pub const SA_RESETHAND: usize = 0x8000_0000;
|
||||
pub const SA_RESTORER: usize = 0x0400_0000;
|
||||
|
||||
pub const SS_ONSTACK: usize = 1;
|
||||
pub const SS_DISABLE: usize = 2;
|
||||
|
||||
// Those two should be updated from kernel headers
|
||||
pub const MINSIGSTKSZ: usize = 2048;
|
||||
pub const SIGSTKSZ: usize = 8096;
|
||||
|
||||
pub const SI_QUEUE: i32 = -1;
|
||||
pub const SI_USER: i32 = 0;
|
||||
pub const SI_TIMER: i32 = 1;
|
||||
pub const SI_ASYNCIO: i32 = 2;
|
||||
pub const SI_MESGQ: i32 = 3;
|
||||
|
||||
// si_code values (signal-specific)
|
||||
pub const ILL_ILLOPC: i32 = 1;
|
||||
pub const ILL_ILLOPN: i32 = 2;
|
||||
pub const ILL_ILLADR: i32 = 3;
|
||||
pub const ILL_ILLTRP: i32 = 4;
|
||||
pub const ILL_PRVOPC: i32 = 5;
|
||||
pub const ILL_PRVREG: i32 = 6;
|
||||
pub const ILL_COPROC: i32 = 7;
|
||||
pub const ILL_BADSTK: i32 = 8;
|
||||
|
||||
pub const FPE_INTDIV: i32 = 1;
|
||||
pub const FPE_INTOVF: i32 = 2;
|
||||
pub const FPE_FLTDIV: i32 = 3;
|
||||
pub const FPE_FLTOVF: i32 = 4;
|
||||
pub const FPE_FLTUND: i32 = 5;
|
||||
pub const FPE_FLTRES: i32 = 6;
|
||||
pub const FPE_FLTINV: i32 = 7;
|
||||
pub const FPE_FLTSUB: i32 = 8;
|
||||
|
||||
pub const SEGV_MAPERR: i32 = 1;
|
||||
pub const SEGV_ACCERR: i32 = 2;
|
||||
|
||||
pub const BUS_ADRALN: i32 = 1;
|
||||
pub const BUS_ADRERR: i32 = 2;
|
||||
pub const BUS_OBJERR: i32 = 3;
|
||||
|
||||
pub const TRAP_BRKPT: i32 = 1;
|
||||
pub const TRAP_TRACE: i32 = 2;
|
||||
|
||||
pub const CLD_EXITED: i32 = 1;
|
||||
pub const CLD_KILLED: i32 = 2;
|
||||
pub const CLD_DUMPED: i32 = 3;
|
||||
pub const CLD_TRAPPED: i32 = 4;
|
||||
pub const CLD_STOPPED: i32 = 5;
|
||||
pub const CLD_CONTINUED: i32 = 6;
|
||||
|
||||
// Mirrors the ucontext_t struct from the libc crate on Linux.
|
||||
|
||||
pub(crate) type ucontext_t = ucontext;
|
||||
|
||||
@@ -17,7 +17,9 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
pub mod constants;
|
||||
pub use self::sys::*;
|
||||
pub use constants::*;
|
||||
|
||||
use super::{
|
||||
errno::EFAULT,
|
||||
|
||||
@@ -6,43 +6,7 @@ use crate::platform::types::{c_uint, c_ulong};
|
||||
|
||||
use super::{siginfo_t, sigset_t, stack_t};
|
||||
|
||||
pub const SIGHUP: usize = 1;
|
||||
pub const SIGINT: usize = 2;
|
||||
pub const SIGQUIT: usize = 3;
|
||||
pub const SIGILL: usize = 4;
|
||||
pub const SIGTRAP: usize = 5;
|
||||
pub const SIGABRT: usize = 6;
|
||||
pub const SIGBUS: usize = 7;
|
||||
pub const SIGFPE: usize = 8;
|
||||
pub const SIGKILL: usize = 9;
|
||||
pub const SIGUSR1: usize = 10;
|
||||
pub const SIGSEGV: usize = 11;
|
||||
pub const SIGUSR2: usize = 12;
|
||||
pub const SIGPIPE: usize = 13;
|
||||
pub const SIGALRM: usize = 14;
|
||||
pub const SIGTERM: usize = 15;
|
||||
pub const SIGSTKFLT: usize = 16;
|
||||
pub const SIGCHLD: usize = 17;
|
||||
pub const SIGCONT: usize = 18;
|
||||
pub const SIGSTOP: usize = 19;
|
||||
pub const SIGTSTP: usize = 20;
|
||||
pub const SIGTTIN: usize = 21;
|
||||
pub const SIGTTOU: usize = 22;
|
||||
pub const SIGURG: usize = 23;
|
||||
pub const SIGXCPU: usize = 24;
|
||||
pub const SIGXFSZ: usize = 25;
|
||||
pub const SIGVTALRM: usize = 26;
|
||||
pub const SIGPROF: usize = 27;
|
||||
pub const SIGWINCH: usize = 28;
|
||||
pub const SIGIO: usize = 29;
|
||||
pub const SIGPWR: usize = 30;
|
||||
pub const SIGSYS: usize = 31;
|
||||
pub const NSIG: usize = 32;
|
||||
|
||||
pub const SIGRTMIN: usize = 35;
|
||||
pub const SIGRTMAX: usize = 64;
|
||||
|
||||
pub const SA_NOCLDWAIT: usize = 0x0000_0002;
|
||||
// TODO why are these SA_* constants different to Linux?
|
||||
pub const SA_RESTORER: usize = 0x0000_0004; // TODO: remove
|
||||
pub const SA_SIGINFO: usize = 0x0200_0000;
|
||||
pub const SA_ONSTACK: usize = 0x0400_0000;
|
||||
@@ -51,68 +15,18 @@ pub const SA_NODEFER: usize = 0x1000_0000;
|
||||
pub const SA_RESETHAND: usize = 0x2000_0000;
|
||||
pub const SA_NOCLDSTOP: usize = 0x4000_0000;
|
||||
|
||||
pub const SS_ONSTACK: usize = 0x00000001;
|
||||
pub const SS_DISABLE: usize = 0x00000002;
|
||||
|
||||
const _: () = {
|
||||
if SS_ONSTACK != redox_rt::signal::SS_ONSTACK {
|
||||
if super::constants::SS_ONSTACK != redox_rt::signal::SS_ONSTACK {
|
||||
panic!();
|
||||
}
|
||||
if SS_DISABLE != redox_rt::signal::SS_DISABLE {
|
||||
if super::constants::SS_DISABLE != redox_rt::signal::SS_DISABLE {
|
||||
panic!();
|
||||
}
|
||||
if MINSIGSTKSZ != redox_rt::signal::MIN_SIGALTSTACK_SIZE {
|
||||
if super::constants::MINSIGSTKSZ != redox_rt::signal::MIN_SIGALTSTACK_SIZE {
|
||||
panic!();
|
||||
}
|
||||
};
|
||||
|
||||
// should include both SigStack size, and some extra room for the libc handler
|
||||
pub const MINSIGSTKSZ: usize = 2048;
|
||||
|
||||
pub const SIGSTKSZ: usize = 8096;
|
||||
|
||||
pub const SI_QUEUE: i32 = -1;
|
||||
pub const SI_USER: i32 = 0;
|
||||
pub const SI_TIMER: i32 = 1;
|
||||
pub const SI_ASYNCIO: i32 = 2;
|
||||
pub const SI_MESGQ: i32 = 3;
|
||||
|
||||
// si_code values (signal-specific)
|
||||
pub const ILL_ILLOPC: i32 = 1;
|
||||
pub const ILL_ILLOPN: i32 = 2;
|
||||
pub const ILL_ILLADR: i32 = 3;
|
||||
pub const ILL_ILLTRP: i32 = 4;
|
||||
pub const ILL_PRVOPC: i32 = 5;
|
||||
pub const ILL_PRVREG: i32 = 6;
|
||||
pub const ILL_COPROC: i32 = 7;
|
||||
pub const ILL_BADSTK: i32 = 8;
|
||||
|
||||
pub const FPE_INTDIV: i32 = 1;
|
||||
pub const FPE_INTOVF: i32 = 2;
|
||||
pub const FPE_FLTDIV: i32 = 3;
|
||||
pub const FPE_FLTOVF: i32 = 4;
|
||||
pub const FPE_FLTUND: i32 = 5;
|
||||
pub const FPE_FLTRES: i32 = 6;
|
||||
pub const FPE_FLTINV: i32 = 7;
|
||||
pub const FPE_FLTSUB: i32 = 8;
|
||||
|
||||
pub const SEGV_MAPERR: i32 = 1;
|
||||
pub const SEGV_ACCERR: i32 = 2;
|
||||
|
||||
pub const BUS_ADRALN: i32 = 1;
|
||||
pub const BUS_ADRERR: i32 = 2;
|
||||
pub const BUS_OBJERR: i32 = 3;
|
||||
|
||||
pub const TRAP_BRKPT: i32 = 1;
|
||||
pub const TRAP_TRACE: i32 = 2;
|
||||
|
||||
pub const CLD_EXITED: i32 = 1;
|
||||
pub const CLD_KILLED: i32 = 2;
|
||||
pub const CLD_DUMPED: i32 = 3;
|
||||
pub const CLD_TRAPPED: i32 = 4;
|
||||
pub const CLD_STOPPED: i32 = 5;
|
||||
pub const CLD_CONTINUED: i32 = 6;
|
||||
|
||||
pub(crate) type ucontext_t = ucontext;
|
||||
pub(crate) type mcontext_t = mcontext;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user