• 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 
83 #define BUS_ADRALN 1
84 #define BUS_ADRERR 2
85 #define BUS_OBJERR 3
86 #define BUS_MCEERR_AR 4
87 #define BUS_MCEERR_AO 5
88 
89 #define CLD_EXITED 1
90 #define CLD_KILLED 2
91 #define CLD_DUMPED 3
92 #define CLD_TRAPPED 4
93 #define CLD_STOPPED 5
94 #define CLD_CONTINUED 6
95 
96 union sigval {
97 	int sival_int;
98 	void *sival_ptr;
99 };
100 
101 typedef struct {
102 	int si_signo, si_errno, si_code;
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 	} __si_fields;
125 } siginfo_t;
126 #define si_pid     __si_fields.__si_common.__first.__piduid.si_pid
127 #define si_uid     __si_fields.__si_common.__first.__piduid.si_uid
128 #define si_status  __si_fields.__si_common.__second.__sigchld.si_status
129 #define si_utime   __si_fields.__si_common.__second.__sigchld.si_utime
130 #define si_stime   __si_fields.__si_common.__second.__sigchld.si_stime
131 #define si_value   __si_fields.__si_common.__second.si_value
132 #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
133 #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
134 
135 struct sigaction {
136 	union {
137 		void (*sa_handler)(int);
138 		void (*sa_sigaction)(int, siginfo_t *, void *);
139 	} sa_sigactionhandler;
140 	sigset_t sa_mask;
141 	int sa_flags;
142 	void (*sa_restorer)(void);
143 };
144 #define sa_handler   sa_sigactionhandler.sa_handler
145 #define sa_sigaction sa_sigactionhandler.sa_sigaction
146 
147 struct sigevent {
148 	union sigval sigev_value;
149 	int sigev_signo;
150 	int sigev_notify;
151 	void (*sigev_notify_function)(union sigval);
152     void *sigev_notify_attributes;
153 };
154 
155 #define SIGEV_SIGNAL 0
156 #define SIGEV_NONE 1
157 #define SIGEV_THREAD 2
158 
159 #define SIGRTMIN  35
160 #define SIGRTMAX  (_NSIG - 1)
161 
162 int pthread_sigmask(int, const sigset_t *, sigset_t *);
163 int sigfillset(sigset_t *);
164 int sigdelset(sigset_t *, int);
165 #endif
166 
167 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
168 void (*sigset(int, void (*)(int)))(int);
169 #define TRAP_BRKPT 1
170 #define TRAP_TRACE 2
171 #define TRAP_BRANCH 3
172 #define TRAP_HWBKPT 4
173 #define TRAP_UNK 5
174 #define POLL_IN 1
175 #define POLL_OUT 2
176 #define POLL_MSG 3
177 #define POLL_ERR 4
178 #define POLL_PRI 5
179 #define POLL_HUP 6
180 #define SS_ONSTACK    1
181 #define SS_DISABLE    2
182 #define SS_AUTODISARM (1U << 31)
183 #define SS_FLAG_BITS SS_AUTODISARM
184 #endif
185 
186 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
187 #define NSIG _NSIG
188 typedef void (*sig_t)(int);
189 #endif
190 
191 #ifdef _GNU_SOURCE
192 typedef void (*sighandler_t)(int);
193 void (*bsd_signal(int, void (*)(int)))(int);
194 
195 #define SA_NOMASK SA_NODEFER
196 #define SA_ONESHOT SA_RESETHAND
197 #endif
198 
199 #define SIG_ERR  ((void (*)(int)) 0)
200 #define SIG_DFL  ((void (*)(int)) 0)
201 #define SIG_IGN  ((void (*)(int)) 0)
202 
203 typedef int sig_atomic_t;
204 
205 void (*signal(int, void (*)(int)))(int);
206 int raise(int);
207 
208 #if _REDIR_TIME64
209 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
210  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
211  || defined(_BSD_SOURCE)
212 __REDIR(sigtimedwait, __sigtimedwait_time64);
213 #endif
214 #endif
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif
221