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