Debian Codegraph @

libc-top-half/musl/include/signal.h

raw
1 #ifndef _WASI_EMULATED_SIGNAL
2 #error "wasm lacks signal support; to enable minimal signal emulation, \
3 compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
4 #else
5 #ifndef _SIGNAL_H
6 #define _SIGNAL_H
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #include <features.h>
13
14 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
15 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
16 || defined(_BSD_SOURCE)
17
18 #ifdef __wasilibc_unmodified_upstream /* WASI has no ucontext support */
19 #ifdef _GNU_SOURCE
20 #define __ucontext ucontext
21 #endif
22
23 #define __NEED_size_t
24 #define __NEED_pid_t
25 #define __NEED_uid_t
26 #define __NEED_struct_timespec
27 #define __NEED_pthread_t
28 #define __NEED_pthread_attr_t
29 #define __NEED_time_t
30 #define __NEED_clock_t
31 #define __NEED_sigset_t
32
33 #include <bits/alltypes.h>
34
35 #define SIG_BLOCK 0
36 #define SIG_UNBLOCK 1
37 #define SIG_SETMASK 2
38
39 #define SI_ASYNCNL (-60)
40 #define SI_TKILL (-6)
41 #define SI_SIGIO (-5)
42 #define SI_ASYNCIO (-4)
43 #define SI_MESGQ (-3)
44 #define SI_TIMER (-2)
45 #define SI_QUEUE (-1)
46 #define SI_USER 0
47 #define SI_KERNEL 128
48
49 typedef struct sigaltstack stack_t;
50 #endif
51
52 #endif
53
54 #include <bits/signal.h>
55
56 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
57 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
58 || defined(_BSD_SOURCE)
59
60 #ifdef __wasilibc_unmodified_upstream /* WASI has no sigaction */
61 #define SIG_HOLD ((void (*)(int)) 2)
62
63 #define FPE_INTDIV 1
64 #define FPE_INTOVF 2
65 #define FPE_FLTDIV 3
66 #define FPE_FLTOVF 4
67 #define FPE_FLTUND 5
68 #define FPE_FLTRES 6
69 #define FPE_FLTINV 7
70 #define FPE_FLTSUB 8
71
72 #define ILL_ILLOPC 1
73 #define ILL_ILLOPN 2
74 #define ILL_ILLADR 3
75 #define ILL_ILLTRP 4
76 #define ILL_PRVOPC 5
77 #define ILL_PRVREG 6
78 #define ILL_COPROC 7
79 #define ILL_BADSTK 8
80
81 #define SEGV_MAPERR 1
82 #define SEGV_ACCERR 2
83 #define SEGV_BNDERR 3
84 #define SEGV_PKUERR 4
85 #define SEGV_MTEAERR 8
86 #define SEGV_MTESERR 9
87
88 #define BUS_ADRALN 1
89 #define BUS_ADRERR 2
90 #define BUS_OBJERR 3
91 #define BUS_MCEERR_AR 4
92 #define BUS_MCEERR_AO 5
93
94 #define CLD_EXITED 1
95 #define CLD_KILLED 2
96 #define CLD_DUMPED 3
97 #define CLD_TRAPPED 4
98 #define CLD_STOPPED 5
99 #define CLD_CONTINUED 6
100
101 union sigval {
102 int sival_int;
103 void *sival_ptr;
104 };
105
106 typedef struct {
107 #ifdef __SI_SWAP_ERRNO_CODE
108 int si_signo, si_code, si_errno;
109 #else
110 int si_signo, si_errno, si_code;
111 #endif
112 union {
113 char __pad[128 - 2*sizeof(int) - sizeof(long)];
114 struct {
115 union {
116 struct {
117 pid_t si_pid;
118 uid_t si_uid;
119 } __piduid;
120 struct {
121 int si_timerid;
122 int si_overrun;
123 } __timer;
124 } __first;
125 union {
126 union sigval si_value;
127 struct {
128 int si_status;
129 clock_t si_utime, si_stime;
130 } __sigchld;
131 } __second;
132 } __si_common;
133 struct {
134 void *si_addr;
135 short si_addr_lsb;
136 union {
137 struct {
138 void *si_lower;
139 void *si_upper;
140 } __addr_bnd;
141 unsigned si_pkey;
142 } __first;
143 } __sigfault;
144 struct {
145 long si_band;
146 int si_fd;
147 } __sigpoll;
148 struct {
149 void *si_call_addr;
150 int si_syscall;
151 unsigned si_arch;
152 } __sigsys;
153 } __si_fields;
154 } siginfo_t;
155 #define si_pid __si_fields.__si_common.__first.__piduid.si_pid
156 #define si_uid __si_fields.__si_common.__first.__piduid.si_uid
157 #define si_status __si_fields.__si_common.__second.__sigchld.si_status
158 #define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
159 #define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
160 #define si_value __si_fields.__si_common.__second.si_value
161 #define si_addr __si_fields.__sigfault.si_addr
162 #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
163 #define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
164 #define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
165 #define si_pkey __si_fields.__sigfault.__first.si_pkey
166 #define si_band __si_fields.__sigpoll.si_band
167 #define si_fd __si_fields.__sigpoll.si_fd
168 #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
169 #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
170 #define si_ptr si_value.sival_ptr
171 #define si_int si_value.sival_int
172 #define si_call_addr __si_fields.__sigsys.si_call_addr
173 #define si_syscall __si_fields.__sigsys.si_syscall
174 #define si_arch __si_fields.__sigsys.si_arch
175
176 struct sigaction {
177 union {
178 void (*sa_handler)(int);
179 void (*sa_sigaction)(int, siginfo_t *, void *);
180 } __sa_handler;
181 sigset_t sa_mask;
182 int sa_flags;
183 void (*sa_restorer)(void);
184 };
185 #define sa_handler __sa_handler.sa_handler
186 #define sa_sigaction __sa_handler.sa_sigaction
187
188 #define SA_UNSUPPORTED 0x00000400
189 #define SA_EXPOSE_TAGBITS 0x00000800
190
191 struct sigevent {
192 union sigval sigev_value;
193 int sigev_signo;
194 int sigev_notify;
195 union {
196 char __pad[64 - 2*sizeof(int) - sizeof(union sigval)];
197 pid_t sigev_notify_thread_id;
198 struct {
199 void (*sigev_notify_function)(union sigval);
200 pthread_attr_t *sigev_notify_attributes;
201 } __sev_thread;
202 } __sev_fields;
203 };
204
205 #define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
206 #define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function
207 #define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes
208
209 #define SIGEV_SIGNAL 0
210 #define SIGEV_NONE 1
211 #define SIGEV_THREAD 2
212 #define SIGEV_THREAD_ID 4
213 #endif
214
215 #ifdef __wasilibc_unmodified_upstream /* WASI has no realtime signals */
216 int __libc_current_sigrtmin(void);
217 int __libc_current_sigrtmax(void);
218
219 #define SIGRTMIN (__libc_current_sigrtmin())
220 #define SIGRTMAX (__libc_current_sigrtmax())
221 #endif
222
223 #ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
224 int kill(pid_t, int);
225
226 int sigemptyset(sigset_t *);
227 int sigfillset(sigset_t *);
228 int sigaddset(sigset_t *, int);
229 int sigdelset(sigset_t *, int);
230 int sigismember(const sigset_t *, int);
231
232 int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
233 int sigsuspend(const sigset_t *);
234 int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
235 int sigpending(sigset_t *);
236 int sigwait(const sigset_t *__restrict, int *__restrict);
237 int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
238 int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
239 int sigqueue(pid_t, int, union sigval);
240 #endif
241
242 #ifdef __wasilibc_unmodified_upstream /* WASI has no threads yet */
243 int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
244 int pthread_kill(pthread_t, int);
245 #endif
246
247 #ifdef __wasilibc_unmodified_upstream /* WASI has no siginfo */
248 void psiginfo(const siginfo_t *, const char *);
249 #endif
250 void psignal(int, const char *);
251
252 #endif
253
254 #ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
255 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
256 int killpg(pid_t, int);
257 int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
258 int sighold(int);
259 int sigignore(int);
260 int siginterrupt(int, int);
261 int sigpause(int);
262 int sigrelse(int);
263 void (*sigset(int, void (*)(int)))(int);
264 #define TRAP_BRKPT 1
265 #define TRAP_TRACE 2
266 #define TRAP_BRANCH 3
267 #define TRAP_HWBKPT 4
268 #define TRAP_UNK 5
269 #define POLL_IN 1
270 #define POLL_OUT 2
271 #define POLL_MSG 3
272 #define POLL_ERR 4
273 #define POLL_PRI 5
274 #define POLL_HUP 6
275 #define SS_ONSTACK 1
276 #define SS_DISABLE 2
277 #define SS_AUTODISARM (1U << 31)
278 #define SS_FLAG_BITS SS_AUTODISARM
279 #endif
280 #endif
281
282 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
283 #define NSIG _NSIG
284 typedef void (*sig_t)(int);
285
286 #define SYS_SECCOMP 1
287 #define SYS_USER_DISPATCH 2
288 #endif
289
290 #ifdef _GNU_SOURCE
291 typedef void (*sighandler_t)(int);
292 void (*bsd_signal(int, void (*)(int)))(int);
293 #ifdef __wasilibc_unmodified_upstream /* WASI has no signal sets */
294 int sigisemptyset(const sigset_t *);
295 int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
296 int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
297
298 #define SA_NOMASK SA_NODEFER
299 #define SA_ONESHOT SA_RESETHAND
300 #endif
301 #endif
302
303 #ifdef __wasilibc_unmodified_upstream /* 1 is a valid function pointer on wasm */
304 #define SIG_ERR ((void (*)(int))-1)
305 #define SIG_DFL ((void (*)(int)) 0)
306 #define SIG_IGN ((void (*)(int)) 1)
307 #else
308 void __SIG_ERR(int);
309 void __SIG_IGN(int);
310 #define SIG_ERR (__SIG_ERR)
311 #define SIG_DFL ((void (*)(int)) 0)
312 #define SIG_IGN (__SIG_IGN)
313 #endif
314
315 #ifdef __wasilibc_unmodified_upstream /* Make sig_atomic_t 64-bit on wasm64 */
316 typedef int sig_atomic_t;
317 #else
318 typedef long sig_atomic_t;
319 #endif
320
321 void (*signal(int, void (*)(int)))(int);
322 int raise(int);
323
324 #ifdef __wasilibc_unmodified_upstream /* WASI has no sigtimedwait */
325 #if _REDIR_TIME64
326 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
327 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
328 || defined(_BSD_SOURCE)
329 __REDIR(sigtimedwait, __sigtimedwait_time64);
330 #endif
331 #endif
332 #endif
333
334 #ifdef __cplusplus
335 }
336 #endif
337
338 #endif
339 #endif