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