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