Update Gnulib to the latest git version
[deliverable/binutils-gdb.git] / gnulib / import / signal.in.h
1 /* A GNU-like <signal.h>.
2
3 Copyright (C) 2006-2019 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
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 /* Special invocation convention:
25 - Inside glibc header files.
26 - On glibc systems we have a sequence of nested includes
27 <signal.h> -> <ucontext.h> -> <signal.h>.
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases.
30 - On glibc systems with GCC 4.3 we have a sequence of nested includes
31 <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
32 In this situation, some of the functions are not yet declared, therefore
33 we cannot provide the C++ aliases. */
34
35 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
36
37 #else
38 /* Normal invocation convention. */
39
40 #ifndef _@GUARD_PREFIX@_SIGNAL_H
41
42 #define _GL_ALREADY_INCLUDING_SIGNAL_H
43
44 /* Define pid_t, uid_t.
45 Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
46 On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
47 us; so include <sys/types.h> now, before the second inclusion guard. */
48 #include <sys/types.h>
49
50 /* The include_next requires a split double-inclusion guard. */
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 /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android
59 declare pthread_sigmask in <pthread.h>, not in <signal.h>.
60 But avoid namespace pollution on glibc systems.*/
61 #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
62 && ((defined __APPLE__ && defined __MACH__) \
63 || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \
64 || defined __sun || defined __ANDROID__) \
65 && ! defined __GLIBC__
66 # include <pthread.h>
67 #endif
68
69 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
70
71 /* The definition of _GL_ARG_NONNULL is copied here. */
72
73 /* The definition of _GL_WARN_ON_USE is copied here. */
74
75 /* On AIX, sig_atomic_t already includes volatile. C99 requires that
76 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
77 Hence, redefine this to a non-volatile type as needed. */
78 #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
79 # if !GNULIB_defined_sig_atomic_t
80 typedef int rpl_sig_atomic_t;
81 # undef sig_atomic_t
82 # define sig_atomic_t rpl_sig_atomic_t
83 # define GNULIB_defined_sig_atomic_t 1
84 # endif
85 #endif
86
87 /* A set or mask of signals. */
88 #if !@HAVE_SIGSET_T@
89 # if !GNULIB_defined_sigset_t
90 typedef unsigned int sigset_t;
91 # define GNULIB_defined_sigset_t 1
92 # endif
93 #endif
94
95 /* Define sighandler_t, the type of signal handlers. A GNU extension. */
96 #if !@HAVE_SIGHANDLER_T@
97 # ifdef __cplusplus
98 extern "C" {
99 # endif
100 # if !GNULIB_defined_sighandler_t
101 typedef void (*sighandler_t) (int);
102 # define GNULIB_defined_sighandler_t 1
103 # endif
104 # ifdef __cplusplus
105 }
106 # endif
107 #endif
108
109
110 #if @GNULIB_SIGNAL_H_SIGPIPE@
111 # ifndef SIGPIPE
112 /* Define SIGPIPE to a value that does not overlap with other signals. */
113 # define SIGPIPE 13
114 # define GNULIB_defined_SIGPIPE 1
115 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
116 'write', 'stdio'. */
117 # endif
118 #endif
119
120
121 /* Maximum signal number + 1. */
122 #ifndef NSIG
123 # if defined __TANDEM
124 # define NSIG 32
125 # endif
126 #endif
127
128
129 #if @GNULIB_PTHREAD_SIGMASK@
130 # if @REPLACE_PTHREAD_SIGMASK@
131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
132 # undef pthread_sigmask
133 # define pthread_sigmask rpl_pthread_sigmask
134 # endif
135 _GL_FUNCDECL_RPL (pthread_sigmask, int,
136 (int how, const sigset_t *new_mask, sigset_t *old_mask));
137 _GL_CXXALIAS_RPL (pthread_sigmask, int,
138 (int how, const sigset_t *new_mask, sigset_t *old_mask));
139 # else
140 # if !(@HAVE_PTHREAD_SIGMASK@ || defined pthread_sigmask)
141 _GL_FUNCDECL_SYS (pthread_sigmask, int,
142 (int how, const sigset_t *new_mask, sigset_t *old_mask));
143 # endif
144 _GL_CXXALIAS_SYS (pthread_sigmask, int,
145 (int how, const sigset_t *new_mask, sigset_t *old_mask));
146 # endif
147 # if __GLIBC__ >= 2
148 _GL_CXXALIASWARN (pthread_sigmask);
149 # endif
150 #elif defined GNULIB_POSIXCHECK
151 # undef pthread_sigmask
152 # if HAVE_RAW_DECL_PTHREAD_SIGMASK
153 _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
154 "use gnulib module pthread_sigmask for portability");
155 # endif
156 #endif
157
158
159 #if @GNULIB_RAISE@
160 # if @REPLACE_RAISE@
161 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
162 # undef raise
163 # define raise rpl_raise
164 # endif
165 _GL_FUNCDECL_RPL (raise, int, (int sig));
166 _GL_CXXALIAS_RPL (raise, int, (int sig));
167 # else
168 # if !@HAVE_RAISE@
169 _GL_FUNCDECL_SYS (raise, int, (int sig));
170 # endif
171 _GL_CXXALIAS_SYS (raise, int, (int sig));
172 # endif
173 # if __GLIBC__ >= 2
174 _GL_CXXALIASWARN (raise);
175 # endif
176 #elif defined GNULIB_POSIXCHECK
177 # undef raise
178 /* Assume raise is always declared. */
179 _GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
180 "use gnulib module raise for portability");
181 #endif
182
183
184 #if @GNULIB_SIGPROCMASK@
185 # if !@HAVE_POSIX_SIGNALBLOCKING@
186
187 # ifndef GNULIB_defined_signal_blocking
188 # define GNULIB_defined_signal_blocking 1
189 # endif
190
191 /* Maximum signal number + 1. */
192 # ifndef NSIG
193 # define NSIG 32
194 # endif
195
196 /* This code supports only 32 signals. */
197 # if !GNULIB_defined_verify_NSIG_constraint
198 typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
199 # define GNULIB_defined_verify_NSIG_constraint 1
200 # endif
201
202 # endif
203
204 /* When also using extern inline, suppress the use of static inline in
205 standard headers of problematic Apple configurations, as Libc at
206 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
207 <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
208 Perhaps Apple will fix this some day. */
209 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
210 && (defined __i386__ || defined __x86_64__))
211 # undef sigaddset
212 # undef sigdelset
213 # undef sigemptyset
214 # undef sigfillset
215 # undef sigismember
216 #endif
217
218 /* Test whether a given signal is contained in a signal set. */
219 # if @HAVE_POSIX_SIGNALBLOCKING@
220 /* This function is defined as a macro on Mac OS X. */
221 # if defined __cplusplus && defined GNULIB_NAMESPACE
222 # undef sigismember
223 # endif
224 # else
225 _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
226 _GL_ARG_NONNULL ((1)));
227 # endif
228 _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
229 _GL_CXXALIASWARN (sigismember);
230
231 /* Initialize a signal set to the empty set. */
232 # if @HAVE_POSIX_SIGNALBLOCKING@
233 /* This function is defined as a macro on Mac OS X. */
234 # if defined __cplusplus && defined GNULIB_NAMESPACE
235 # undef sigemptyset
236 # endif
237 # else
238 _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
239 # endif
240 _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
241 _GL_CXXALIASWARN (sigemptyset);
242
243 /* Add a signal to a signal set. */
244 # if @HAVE_POSIX_SIGNALBLOCKING@
245 /* This function is defined as a macro on Mac OS X. */
246 # if defined __cplusplus && defined GNULIB_NAMESPACE
247 # undef sigaddset
248 # endif
249 # else
250 _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
251 _GL_ARG_NONNULL ((1)));
252 # endif
253 _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
254 _GL_CXXALIASWARN (sigaddset);
255
256 /* Remove a signal from a signal set. */
257 # if @HAVE_POSIX_SIGNALBLOCKING@
258 /* This function is defined as a macro on Mac OS X. */
259 # if defined __cplusplus && defined GNULIB_NAMESPACE
260 # undef sigdelset
261 # endif
262 # else
263 _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
264 _GL_ARG_NONNULL ((1)));
265 # endif
266 _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
267 _GL_CXXALIASWARN (sigdelset);
268
269 /* Fill a signal set with all possible signals. */
270 # if @HAVE_POSIX_SIGNALBLOCKING@
271 /* This function is defined as a macro on Mac OS X. */
272 # if defined __cplusplus && defined GNULIB_NAMESPACE
273 # undef sigfillset
274 # endif
275 # else
276 _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
277 # endif
278 _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
279 _GL_CXXALIASWARN (sigfillset);
280
281 /* Return the set of those blocked signals that are pending. */
282 # if !@HAVE_POSIX_SIGNALBLOCKING@
283 _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
284 # endif
285 _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
286 _GL_CXXALIASWARN (sigpending);
287
288 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
289 Then, if SET is not NULL, affect the current set of blocked signals by
290 combining it with *SET as indicated in OPERATION.
291 In this implementation, you are not allowed to change a signal handler
292 while the signal is blocked. */
293 # if !@HAVE_POSIX_SIGNALBLOCKING@
294 # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */
295 # define SIG_SETMASK 1 /* blocked_set = *set; */
296 # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */
297 _GL_FUNCDECL_SYS (sigprocmask, int,
298 (int operation, const sigset_t *set, sigset_t *old_set));
299 # endif
300 _GL_CXXALIAS_SYS (sigprocmask, int,
301 (int operation, const sigset_t *set, sigset_t *old_set));
302 _GL_CXXALIASWARN (sigprocmask);
303
304 /* Install the handler FUNC for signal SIG, and return the previous
305 handler. */
306 # ifdef __cplusplus
307 extern "C" {
308 # endif
309 # if !GNULIB_defined_function_taking_int_returning_void_t
310 typedef void (*_gl_function_taking_int_returning_void_t) (int);
311 # define GNULIB_defined_function_taking_int_returning_void_t 1
312 # endif
313 # ifdef __cplusplus
314 }
315 # endif
316 # if !@HAVE_POSIX_SIGNALBLOCKING@
317 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
318 # define signal rpl_signal
319 # endif
320 _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
321 (int sig, _gl_function_taking_int_returning_void_t func));
322 _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
323 (int sig, _gl_function_taking_int_returning_void_t func));
324 # else
325 /* On OpenBSD, the declaration of 'signal' may not be present at this point,
326 because it occurs in <sys/signal.h>, not <signal.h> directly. */
327 # if defined __OpenBSD__
328 _GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t,
329 (int sig, _gl_function_taking_int_returning_void_t func));
330 # endif
331 _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
332 (int sig, _gl_function_taking_int_returning_void_t func));
333 # endif
334 # if __GLIBC__ >= 2
335 _GL_CXXALIASWARN (signal);
336 # endif
337
338 # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE
339 /* Raise signal SIGPIPE. */
340 _GL_EXTERN_C int _gl_raise_SIGPIPE (void);
341 # endif
342
343 #elif defined GNULIB_POSIXCHECK
344 # undef sigaddset
345 # if HAVE_RAW_DECL_SIGADDSET
346 _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
347 "use the gnulib module sigprocmask for portability");
348 # endif
349 # undef sigdelset
350 # if HAVE_RAW_DECL_SIGDELSET
351 _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
352 "use the gnulib module sigprocmask for portability");
353 # endif
354 # undef sigemptyset
355 # if HAVE_RAW_DECL_SIGEMPTYSET
356 _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
357 "use the gnulib module sigprocmask for portability");
358 # endif
359 # undef sigfillset
360 # if HAVE_RAW_DECL_SIGFILLSET
361 _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
362 "use the gnulib module sigprocmask for portability");
363 # endif
364 # undef sigismember
365 # if HAVE_RAW_DECL_SIGISMEMBER
366 _GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
367 "use the gnulib module sigprocmask for portability");
368 # endif
369 # undef sigpending
370 # if HAVE_RAW_DECL_SIGPENDING
371 _GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
372 "use the gnulib module sigprocmask for portability");
373 # endif
374 # undef sigprocmask
375 # if HAVE_RAW_DECL_SIGPROCMASK
376 _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
377 "use the gnulib module sigprocmask for portability");
378 # endif
379 #endif /* @GNULIB_SIGPROCMASK@ */
380
381
382 #if @GNULIB_SIGACTION@
383 # if !@HAVE_SIGACTION@
384
385 # if !@HAVE_SIGINFO_T@
386
387 # if !GNULIB_defined_siginfo_types
388
389 /* Present to allow compilation, but unsupported by gnulib. */
390 union sigval
391 {
392 int sival_int;
393 void *sival_ptr;
394 };
395
396 /* Present to allow compilation, but unsupported by gnulib. */
397 struct siginfo_t
398 {
399 int si_signo;
400 int si_code;
401 int si_errno;
402 pid_t si_pid;
403 uid_t si_uid;
404 void *si_addr;
405 int si_status;
406 long si_band;
407 union sigval si_value;
408 };
409 typedef struct siginfo_t siginfo_t;
410
411 # define GNULIB_defined_siginfo_types 1
412 # endif
413
414 # endif /* !@HAVE_SIGINFO_T@ */
415
416 /* We assume that platforms which lack the sigaction() function also lack
417 the 'struct sigaction' type, and vice versa. */
418
419 # if !GNULIB_defined_struct_sigaction
420
421 struct sigaction
422 {
423 union
424 {
425 void (*_sa_handler) (int);
426 /* Present to allow compilation, but unsupported by gnulib. POSIX
427 says that implementations may, but not must, make sa_sigaction
428 overlap with sa_handler, but we know of no implementation where
429 they do not overlap. */
430 void (*_sa_sigaction) (int, siginfo_t *, void *);
431 } _sa_func;
432 sigset_t sa_mask;
433 /* Not all POSIX flags are supported. */
434 int sa_flags;
435 };
436 # define sa_handler _sa_func._sa_handler
437 # define sa_sigaction _sa_func._sa_sigaction
438 /* Unsupported flags are not present. */
439 # define SA_RESETHAND 1
440 # define SA_NODEFER 2
441 # define SA_RESTART 4
442
443 # define GNULIB_defined_struct_sigaction 1
444 # endif
445
446 _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
447 struct sigaction *restrict));
448
449 # elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
450
451 # define sa_sigaction sa_handler
452
453 # endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
454
455 _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
456 struct sigaction *restrict));
457 _GL_CXXALIASWARN (sigaction);
458
459 #elif defined GNULIB_POSIXCHECK
460 # undef sigaction
461 # if HAVE_RAW_DECL_SIGACTION
462 _GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
463 "use the gnulib module sigaction for portability");
464 # endif
465 #endif
466
467 /* Some systems don't have SA_NODEFER. */
468 #ifndef SA_NODEFER
469 # define SA_NODEFER 0
470 #endif
471
472
473 #endif /* _@GUARD_PREFIX@_SIGNAL_H */
474 #endif /* _@GUARD_PREFIX@_SIGNAL_H */
475 #endif
This page took 0.050932 seconds and 4 git commands to generate.