• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_struct_cpu_set_t
19 #define __NEED_struct_sched_param
20 
21 #define __NEED_size_t
22 #define __NEED_pid_t
23 #define __NEED_uid_t
24 #define __NEED_struct_timespec
25 #define __NEED_pthread_t
26 #define __NEED_pthread_attr_t
27 #define __NEED_time_t
28 #define __NEED_clock_t
29 #define __NEED_sigset_t
30 
31 #include <bits/alltypes.h>
32 
33 #define SIG_BLOCK     0
34 #define SIG_UNBLOCK   1
35 #define SIG_SETMASK   2
36 #define NUM_SIGNAL_ACTIONS 16
37 
38 #define SI_ASYNCNL (-60)
39 #define SI_TKILL (-6)
40 #define SI_SIGIO (-5)
41 #define SI_ASYNCIO 4
42 #define SI_MESGQ 5
43 #define SI_TIMER (-2)
44 #define SI_QUEUE 2
45 #define SI_USER 1
46 #define SI_KERNEL 128
47 
48 typedef struct sigaltstack stack_t;
49 
50 #endif
51 
52 #include <bits/signal.h>
53 
54 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
55  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
56  || defined(_BSD_SOURCE)
57 
58 #define SIG_HOLD ((void (*)(int)) 2)
59 
60 #define FPE_INTDIV 1
61 #define FPE_INTOVF 2
62 #define FPE_FLTDIV 3
63 #define FPE_FLTOVF 4
64 #define FPE_FLTUND 5
65 #define FPE_FLTRES 6
66 #define FPE_FLTINV 7
67 #define FPE_FLTSUB 8
68 
69 #define ILL_ILLOPC 1
70 #define ILL_ILLOPN 2
71 #define ILL_ILLADR 3
72 #define ILL_ILLTRP 4
73 #define ILL_PRVOPC 5
74 #define ILL_PRVREG 6
75 #define ILL_COPROC 7
76 #define ILL_BADSTK 8
77 
78 #define SEGV_MAPERR 1
79 #define SEGV_ACCERR 2
80 #define SEGV_BNDERR 3
81 #define SEGV_PKUERR 4
82 #define SEGV_MTEAERR 8
83 #define SEGV_MTESERR 9
84 
85 #define BUS_ADRALN 1
86 #define BUS_ADRERR 2
87 #define BUS_OBJERR 3
88 #define BUS_MCEERR_AR 4
89 #define BUS_MCEERR_AO 5
90 
91 #define CLD_EXITED 1
92 #define CLD_KILLED 2
93 #define CLD_DUMPED 3
94 #define CLD_TRAPPED 4
95 #define CLD_STOPPED 5
96 #define CLD_CONTINUED 6
97 
98 union sigval {
99 	int sival_int;
100 	void *sival_ptr;
101 };
102 
103 typedef struct {
104 	int si_signo, si_errno, si_code;
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 	} __si_fields;
127 } siginfo_t;
128 #define si_pid     __si_fields.__si_common.__first.__piduid.si_pid
129 #define si_uid     __si_fields.__si_common.__first.__piduid.si_uid
130 #define si_status  __si_fields.__si_common.__second.__sigchld.si_status
131 #define si_utime   __si_fields.__si_common.__second.__sigchld.si_utime
132 #define si_stime   __si_fields.__si_common.__second.__sigchld.si_stime
133 #define si_value   __si_fields.__si_common.__second.si_value
134 #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
135 #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
136 
137 struct sigaction {
138 	union {
139 		void (*sa_handler)(int);
140 		void (*sa_sigaction)(int, siginfo_t *, void *);
141 	} sa_sigactionhandler;
142 	sigset_t sa_mask;
143 	int sa_flags;
144 	void (*sa_restorer)(void);
145 };
146 #define sa_handler   sa_sigactionhandler.sa_handler
147 #define sa_sigaction sa_sigactionhandler.sa_sigaction
148 
149 #define SA_UNSUPPORTED 0x00000400
150 #define SA_EXPOSE_TAGBITS 0x00000800
151 
152 struct sigevent {
153 	union sigval sigev_value;
154 	int sigev_signo;
155 	int sigev_notify;
156 	union {
157 		char __pad[64 - 2*sizeof(int) - sizeof(union sigval)];
158 		pid_t sigev_notify_thread_id;
159 		struct {
160 			void (*sigev_notify_function)(union sigval);
161 			pthread_attr_t *sigev_notify_attributes;
162 		} __sev_thread;
163 	} __sev_fields;
164 };
165 
166 #define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
167 #define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function
168 #define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes
169 
170 #define SIGEV_SIGNAL 0
171 #define SIGEV_NONE 1
172 #define SIGEV_THREAD 2
173 #define SIGEV_THREAD_ID 4
174 
175 #define SIGRTMIN  35
176 #define SIGRTMAX  (_NSIG - 1)
177 
178 int pthread_sigmask(int, const sigset_t *, sigset_t *);
179 int sigfillset(sigset_t *);
180 int sigdelset(sigset_t *, int);
181 #endif
182 
183 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
184 void (*sigset(int, void (*)(int)))(int);
185 #define TRAP_BRKPT 1
186 #define TRAP_TRACE 2
187 #define TRAP_BRANCH 3
188 #define TRAP_HWBKPT 4
189 #define TRAP_UNK 5
190 #define POLL_IN 1
191 #define POLL_OUT 2
192 #define POLL_MSG 3
193 #define POLL_ERR 4
194 #define POLL_PRI 5
195 #define POLL_HUP 6
196 #define SS_ONSTACK    1
197 #define SS_DISABLE    2
198 #define SS_AUTODISARM (1U << 31)
199 #define SS_FLAG_BITS SS_AUTODISARM
200 #endif
201 
202 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
203 #define NSIG _NSIG
204 typedef void (*sig_t)(int);
205 
206 #define SYS_SECCOMP 1
207 #define SYS_USER_DISPATCH 2
208 #endif
209 
210 #ifdef _GNU_SOURCE
211 typedef void (*sighandler_t)(int);
212 void (*bsd_signal(int, void (*)(int)))(int);
213 
214 #define SA_NOMASK SA_NODEFER
215 #define SA_ONESHOT SA_RESETHAND
216 #endif
217 
218 #define SIG_ERR  ((void (*)(int)) 0)
219 #define SIG_DFL  ((void (*)(int)) 0)
220 #define SIG_IGN  ((void (*)(int)) 0)
221 
222 typedef int sig_atomic_t;
223 
224 void (*signal(int, void (*)(int)))(int);
225 int raise(int);
226 
227 #if _REDIR_TIME64
228 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
229  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
230  || defined(_BSD_SOURCE)
231 __REDIR(sigtimedwait, __sigtimedwait_time64);
232 #endif
233 #endif
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 
239 #endif
240