interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / new / qurt / signal.rs

119 lines · 3644 bytes Raw Blame History
1//! Header: `signal.h`
2
3use super::*;
4use crate::prelude::*;
5
6// Signal numbers from toolchain signal.h (non-_LINUX_C_LIB_H_ path)
7pub const SIGHUP: c_int = 1;
8pub const SIGINT: c_int = 2;
9pub const SIGQUIT: c_int = 3;
10pub const SIGILL: c_int = 4;
11pub const SIGTRAP: c_int = 5;
12pub const SIGABRT: c_int = 6;
13pub const SIGIOT: c_int = 6;
14pub const SIGBUS: c_int = 7;
15pub const SIGFPE: c_int = 8;
16pub const SIGKILL: c_int = 9;
17pub const SIGUSR1: c_int = 10;
18pub const SIGSEGV: c_int = 11;
19pub const SIGUSR2: c_int = 12;
20pub const SIGPIPE: c_int = 13;
21pub const SIGALRM: c_int = 14;
22pub const SIGTERM: c_int = 15;
23pub const SIGSTKFLT: c_int = 16;
24pub const SIGCHLD: c_int = 17;
25pub const SIGCONT: c_int = 18;
26pub const SIGSTOP: c_int = 19;
27pub const SIGTSTP: c_int = 20;
28pub const SIGTTIN: c_int = 21;
29pub const SIGTTOU: c_int = 22;
30pub const SIGURG: c_int = 23;
31pub const SIGXCPU: c_int = 24;
32pub const SIGXFSZ: c_int = 25;
33pub const SIGPROF: c_int = 27;
34pub const SIGWINCH: c_int = 28;
35pub const SIGPOLL: c_int = 29;
36pub const SIGIO: c_int = 29;
37pub const SIGPWR: c_int = 30;
38pub const SIGSYS: c_int = 31;
39
40// Signal handling constants
41pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
42pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
43pub const SIG_ERR: sighandler_t = !0 as sighandler_t;
44
45// Signal mask operations (QuRT uses different values than Linux)
46pub const SIG_BLOCK: c_int = 1;
47pub const SIG_UNBLOCK: c_int = 2;
48pub const SIG_SETMASK: c_int = 3;
49
50// QuRT-specific signal constants
51pub const POSIX_MSG: c_int = 7;
52pub const POSIX_NOTIF: c_int = 8;
53pub const SIGRTMIN: c_int = 10;
54
55/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
56/// for details.
57pub const SIGRTMAX: c_int = 32;
58
59// Notification types (from QuRT signal.h)
60pub const SIGEV_NONE: c_int = 0;
61pub const SIGEV_SIGNAL: c_int = 1;
62pub const SIGEV_THREAD: c_int = 2;
63pub const SA_SIGINFO: c_int = 1;
64
65pub type sighandler_t = size_t;
66
67// Signal structures based on QuRT SDK headers
68
69// sigval is a union in C (4 bytes on 32-bit hexagon)
70s_no_extra_traits! {
71 pub union sigval {
72 pub sival_int: c_int,
73 pub sival_ptr: *mut c_void,
74 }
75}
76
77s! {
78 pub struct sigevent {
79 pub sigev_notify: c_int,
80 pub sigev_signo: c_int,
81 pub sigev_value: sigval,
82 pub sigev_notify_function: Option<extern "C" fn(sigval)>,
83 pub sigev_notify_attributes: *mut pthread_attr_t,
84 }
85
86 pub struct siginfo_t {
87 pub si_signo: c_int,
88 pub si_code: c_int,
89 pub si_value: sigval,
90 }
91
92 pub struct sigaction {
93 pub sa_handler: Option<extern "C" fn(c_int)>,
94 pub sa_mask: sigset_t,
95 pub sa_flags: c_int,
96 pub sa_sigaction: Option<extern "C" fn(c_int, *mut siginfo_t, *mut c_void)>,
97 }
98}
99
100extern "C" {
101 // From generic signal.h (toolchain)
102 pub fn signal(sig: c_int, handler: sighandler_t) -> sighandler_t;
103 pub fn raise(sig: c_int) -> c_int;
104
105 // QuRT POSIX signal functions
106 pub fn sigemptyset(set: *mut sigset_t) -> c_int;
107 pub fn sigfillset(set: *mut sigset_t) -> c_int;
108 pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int;
109 pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int;
110 pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int;
111 pub fn sigsuspend(mask: *const sigset_t) -> c_int;
112 pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
113 pub fn _sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int;
114 pub fn sigtimedwait(
115 set: *const sigset_t,
116 info: *mut siginfo_t,
117 timeout: *const timespec,
118 ) -> c_int;
119}