1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21 @PRAGMA_COLUMNS@
22
23 #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
24
25
26
27
28
29
30
31
32
33
34
35 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
36
37 #else
38
39
40 #ifndef _@GUARD_PREFIX@_SIGNAL_H
41
42 #define _GL_ALREADY_INCLUDING_SIGNAL_H
43
44
45
46
47
48 #include <sys/types.h>
49
50
51 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
52
53 #undef _GL_ALREADY_INCLUDING_SIGNAL_H
54
55 #ifndef _@GUARD_PREFIX@_SIGNAL_H
56 #define _@GUARD_PREFIX@_SIGNAL_H
57
58
59 #if !_GL_CONFIG_H_INCLUDED
60 #error "Please include config.h first."
61 #endif
62
63
64 #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
65 && defined __OpenBSD__
66 # include <sys/param.h>
67 #endif
68
69
70
71
72 #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
73 && ((defined __APPLE__ && defined __MACH__) \
74 || (defined __FreeBSD__ && __FreeBSD__ < 8) \
75 || (defined __OpenBSD__ && OpenBSD < 201205) \
76 || defined __osf__ || defined __sun || defined __ANDROID__ \
77 || defined __KLIBC__) \
78 && ! defined __GLIBC__
79 # include <pthread.h>
80 #endif
81
82
83
84
85
86
87
88
89
90
91 #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
92 # if !GNULIB_defined_sig_atomic_t
93 typedef int rpl_sig_atomic_t;
94 # undef sig_atomic_t
95 # define sig_atomic_t rpl_sig_atomic_t
96 # define GNULIB_defined_sig_atomic_t 1
97 # endif
98 #endif
99
100
101 #if !@HAVE_SIGSET_T@
102 # if !GNULIB_defined_sigset_t
103 typedef unsigned int sigset_t;
104 # define GNULIB_defined_sigset_t 1
105 # endif
106 #endif
107
108
109 #if !@HAVE_SIGHANDLER_T@
110 # ifdef __cplusplus
111 extern "C" {
112 # endif
113 # if !GNULIB_defined_sighandler_t
114 typedef void (*sighandler_t) (int);
115 # define GNULIB_defined_sighandler_t 1
116 # endif
117 # ifdef __cplusplus
118 }
119 # endif
120 #endif
121
122
123 #if @GNULIB_SIGNAL_H_SIGPIPE@
124 # ifndef SIGPIPE
125
126 # define SIGPIPE 13
127 # define GNULIB_defined_SIGPIPE 1
128
129
130 # endif
131 #endif
132
133
134
135 #ifndef NSIG
136 # if defined __TANDEM
137 # define NSIG 32
138 # endif
139 #endif
140
141
142 #if @GNULIB_PTHREAD_SIGMASK@
143 # if @REPLACE_PTHREAD_SIGMASK@
144 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
145 # undef pthread_sigmask
146 # define pthread_sigmask rpl_pthread_sigmask
147 # endif
148 _GL_FUNCDECL_RPL (pthread_sigmask, int,
149 (int how,
150 const sigset_t *restrict new_mask,
151 sigset_t *restrict old_mask));
152 _GL_CXXALIAS_RPL (pthread_sigmask, int,
153 (int how,
154 const sigset_t *restrict new_mask,
155 sigset_t *restrict old_mask));
156 # else
157 # if !(@HAVE_PTHREAD_SIGMASK@ || defined pthread_sigmask)
158 _GL_FUNCDECL_SYS (pthread_sigmask, int,
159 (int how,
160 const sigset_t *restrict new_mask,
161 sigset_t *restrict old_mask));
162 # endif
163 _GL_CXXALIAS_SYS (pthread_sigmask, int,
164 (int how,
165 const sigset_t *restrict new_mask,
166 sigset_t *restrict old_mask));
167 # endif
168 # if __GLIBC__ >= 2
169 _GL_CXXALIASWARN (pthread_sigmask);
170 # endif
171 #elif defined GNULIB_POSIXCHECK
172 # undef pthread_sigmask
173 # if HAVE_RAW_DECL_PTHREAD_SIGMASK
174 _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
175 "use gnulib module pthread_sigmask for portability");
176 # endif
177 #endif
178
179
180 #if @GNULIB_RAISE@
181 # if @REPLACE_RAISE@
182 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
183 # undef raise
184 # define raise rpl_raise
185 # endif
186 _GL_FUNCDECL_RPL (raise, int, (int sig));
187 _GL_CXXALIAS_RPL (raise, int, (int sig));
188 # else
189 # if !@HAVE_RAISE@
190 _GL_FUNCDECL_SYS (raise, int, (int sig));
191 # endif
192 _GL_CXXALIAS_SYS (raise, int, (int sig));
193 # endif
194 # if __GLIBC__ >= 2
195 _GL_CXXALIASWARN (raise);
196 # endif
197 #elif defined GNULIB_POSIXCHECK
198 # undef raise
199
200 _GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
201 "use gnulib module raise for portability");
202 #endif
203
204
205 #if @GNULIB_SIGPROCMASK@
206 # if !@HAVE_POSIX_SIGNALBLOCKING@
207
208 # ifndef GNULIB_defined_signal_blocking
209 # define GNULIB_defined_signal_blocking 1
210 # endif
211
212
213 # ifndef NSIG
214 # define NSIG 32
215 # endif
216
217
218 # if !GNULIB_defined_verify_NSIG_constraint
219 typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
220 # define GNULIB_defined_verify_NSIG_constraint 1
221 # endif
222
223 # endif
224
225
226
227
228
229
230 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
231 && (defined __i386__ || defined __x86_64__))
232 # undef sigaddset
233 # undef sigdelset
234 # undef sigemptyset
235 # undef sigfillset
236 # undef sigismember
237 #endif
238
239
240 # if @HAVE_POSIX_SIGNALBLOCKING@
241
242 # if defined __cplusplus && defined GNULIB_NAMESPACE
243 # undef sigismember
244 # endif
245 # else
246 _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
247 _GL_ARG_NONNULL ((1)));
248 # endif
249 _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
250 _GL_CXXALIASWARN (sigismember);
251
252
253 # if @HAVE_POSIX_SIGNALBLOCKING@
254
255 # if defined __cplusplus && defined GNULIB_NAMESPACE
256 # undef sigemptyset
257 # endif
258 # else
259 _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
260 # endif
261 _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
262 _GL_CXXALIASWARN (sigemptyset);
263
264
265 # if @HAVE_POSIX_SIGNALBLOCKING@
266
267 # if defined __cplusplus && defined GNULIB_NAMESPACE
268 # undef sigaddset
269 # endif
270 # else
271 _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
272 _GL_ARG_NONNULL ((1)));
273 # endif
274 _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
275 _GL_CXXALIASWARN (sigaddset);
276
277
278 # if @HAVE_POSIX_SIGNALBLOCKING@
279
280 # if defined __cplusplus && defined GNULIB_NAMESPACE
281 # undef sigdelset
282 # endif
283 # else
284 _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
285 _GL_ARG_NONNULL ((1)));
286 # endif
287 _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
288 _GL_CXXALIASWARN (sigdelset);
289
290
291 # if @HAVE_POSIX_SIGNALBLOCKING@
292
293 # if defined __cplusplus && defined GNULIB_NAMESPACE
294 # undef sigfillset
295 # endif
296 # else
297 _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
298 # endif
299 _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
300 _GL_CXXALIASWARN (sigfillset);
301
302
303 # if !@HAVE_POSIX_SIGNALBLOCKING@
304 _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
305 # endif
306 _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
307 _GL_CXXALIASWARN (sigpending);
308
309
310
311
312
313
314 # if !@HAVE_POSIX_SIGNALBLOCKING@
315 # define SIG_BLOCK 0
316 # define SIG_SETMASK 1
317 # define SIG_UNBLOCK 2
318 _GL_FUNCDECL_SYS (sigprocmask, int,
319 (int operation,
320 const sigset_t *restrict set,
321 sigset_t *restrict old_set));
322 # endif
323 _GL_CXXALIAS_SYS (sigprocmask, int,
324 (int operation,
325 const sigset_t *restrict set,
326 sigset_t *restrict old_set));
327 _GL_CXXALIASWARN (sigprocmask);
328
329
330
331 # ifdef __cplusplus
332 extern "C" {
333 # endif
334 # if !GNULIB_defined_function_taking_int_returning_void_t
335 typedef void (*_gl_function_taking_int_returning_void_t) (int);
336 # define GNULIB_defined_function_taking_int_returning_void_t 1
337 # endif
338 # ifdef __cplusplus
339 }
340 # endif
341 # if !@HAVE_POSIX_SIGNALBLOCKING@
342 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
343 # define signal rpl_signal
344 # endif
345 _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
346 (int sig, _gl_function_taking_int_returning_void_t func));
347 _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
348 (int sig, _gl_function_taking_int_returning_void_t func));
349 # else
350
351
352 # if defined __OpenBSD__
353 _GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t,
354 (int sig, _gl_function_taking_int_returning_void_t func));
355 # endif
356 _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
357 (int sig, _gl_function_taking_int_returning_void_t func));
358 # endif
359 # if __GLIBC__ >= 2
360 _GL_CXXALIASWARN (signal);
361 # endif
362
363 # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE
364
365 _GL_EXTERN_C int _gl_raise_SIGPIPE (void);
366 # endif
367
368 #elif defined GNULIB_POSIXCHECK
369 # undef sigaddset
370 # if HAVE_RAW_DECL_SIGADDSET
371 _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
372 "use the gnulib module sigprocmask for portability");
373 # endif
374 # undef sigdelset
375 # if HAVE_RAW_DECL_SIGDELSET
376 _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
377 "use the gnulib module sigprocmask for portability");
378 # endif
379 # undef sigemptyset
380 # if HAVE_RAW_DECL_SIGEMPTYSET
381 _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
382 "use the gnulib module sigprocmask for portability");
383 # endif
384 # undef sigfillset
385 # if HAVE_RAW_DECL_SIGFILLSET
386 _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
387 "use the gnulib module sigprocmask for portability");
388 # endif
389 # undef sigismember
390 # if HAVE_RAW_DECL_SIGISMEMBER
391 _GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
392 "use the gnulib module sigprocmask for portability");
393 # endif
394 # undef sigpending
395 # if HAVE_RAW_DECL_SIGPENDING
396 _GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
397 "use the gnulib module sigprocmask for portability");
398 # endif
399 # undef sigprocmask
400 # if HAVE_RAW_DECL_SIGPROCMASK
401 _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
402 "use the gnulib module sigprocmask for portability");
403 # endif
404 #endif
405
406
407 #if @GNULIB_SIGACTION@
408 # if !@HAVE_SIGACTION@
409
410 # if !@HAVE_SIGINFO_T@
411
412 # if !GNULIB_defined_siginfo_types
413
414
415 union sigval
416 {
417 int sival_int;
418 void *sival_ptr;
419 };
420
421
422 struct siginfo_t
423 {
424 int si_signo;
425 int si_code;
426 int si_errno;
427 pid_t si_pid;
428 uid_t si_uid;
429 void *si_addr;
430 int si_status;
431 long si_band;
432 union sigval si_value;
433 };
434 typedef struct siginfo_t siginfo_t;
435
436 # define GNULIB_defined_siginfo_types 1
437 # endif
438
439 # endif
440
441
442
443
444 # if !GNULIB_defined_struct_sigaction
445
446 struct sigaction
447 {
448 union
449 {
450 void (*_sa_handler) (int);
451
452
453
454
455 void (*_sa_sigaction) (int, siginfo_t *, void *);
456 } _sa_func;
457 sigset_t sa_mask;
458
459 int sa_flags;
460 };
461 # define sa_handler _sa_func._sa_handler
462 # define sa_sigaction _sa_func._sa_sigaction
463
464 # define SA_RESETHAND 1
465 # define SA_NODEFER 2
466 # define SA_RESTART 4
467
468 # define GNULIB_defined_struct_sigaction 1
469 # endif
470
471 _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
472 struct sigaction *restrict));
473
474 # elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
475
476 # define sa_sigaction sa_handler
477
478 # endif
479
480 _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
481 struct sigaction *restrict));
482 _GL_CXXALIASWARN (sigaction);
483
484 #elif defined GNULIB_POSIXCHECK
485 # undef sigaction
486 # if HAVE_RAW_DECL_SIGACTION
487 _GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
488 "use the gnulib module sigaction for portability");
489 # endif
490 #endif
491
492
493 #ifndef SA_NODEFER
494 # define SA_NODEFER 0
495 #endif
496
497
498 #endif
499 #endif
500 #endif