87f7471b89019449f52f00386577fb08a6e18909
[debian/tar] / gnu / signal.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A GNU-like <signal.h>.
4
5    Copyright (C) 2006-2013 Free Software Foundation, Inc.
6
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23 @PRAGMA_COLUMNS@
24
25 #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T)
26 /* Special invocation convention:
27    - Inside glibc header files.
28    - On glibc systems we have a sequence of nested includes
29      <signal.h> -> <ucontext.h> -> <signal.h>.
30      In this situation, the functions are not yet declared, therefore we cannot
31      provide the C++ aliases.
32    - On glibc systems with GCC 4.3 we have a sequence of nested includes
33      <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>.
34      In this situation, some of the functions are not yet declared, therefore
35      we cannot provide the C++ aliases.  */
36
37 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
38
39 #else
40 /* Normal invocation convention.  */
41
42 #ifndef _@GUARD_PREFIX@_SIGNAL_H
43
44 #define _GL_ALREADY_INCLUDING_SIGNAL_H
45
46 /* Define pid_t, uid_t.
47    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.
48    On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes
49    us; so include <sys/types.h> now, before the second inclusion guard.  */
50 #include <sys/types.h>
51
52 /* The include_next requires a split double-inclusion guard.  */
53 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
54
55 #undef _GL_ALREADY_INCLUDING_SIGNAL_H
56
57 #ifndef _@GUARD_PREFIX@_SIGNAL_H
58 #define _@GUARD_PREFIX@_SIGNAL_H
59
60 /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6 declare
61    pthread_sigmask in <pthread.h>, not in <signal.h>.
62    But avoid namespace pollution on glibc systems.*/
63 #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
64     && ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ || defined __sun) \
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@
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 _GL_CXXALIASWARN (pthread_sigmask);
148 #elif defined GNULIB_POSIXCHECK
149 # undef pthread_sigmask
150 # if HAVE_RAW_DECL_PTHREAD_SIGMASK
151 _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
152                  "use gnulib module pthread_sigmask for portability");
153 # endif
154 #endif
155
156
157 #if @GNULIB_RAISE@
158 # if @REPLACE_RAISE@
159 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
160 #   undef raise
161 #   define raise rpl_raise
162 #  endif
163 _GL_FUNCDECL_RPL (raise, int, (int sig));
164 _GL_CXXALIAS_RPL (raise, int, (int sig));
165 # else
166 #  if !@HAVE_RAISE@
167 _GL_FUNCDECL_SYS (raise, int, (int sig));
168 #  endif
169 _GL_CXXALIAS_SYS (raise, int, (int sig));
170 # endif
171 _GL_CXXALIASWARN (raise);
172 #elif defined GNULIB_POSIXCHECK
173 # undef raise
174 /* Assume raise is always declared.  */
175 _GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
176                  "use gnulib module raise for portability");
177 #endif
178
179
180 #if @GNULIB_SIGPROCMASK@
181 # if !@HAVE_POSIX_SIGNALBLOCKING@
182
183 #  ifndef GNULIB_defined_signal_blocking
184 #   define GNULIB_defined_signal_blocking 1
185 #  endif
186
187 /* Maximum signal number + 1.  */
188 #  ifndef NSIG
189 #   define NSIG 32
190 #  endif
191
192 /* This code supports only 32 signals.  */
193 #  if !GNULIB_defined_verify_NSIG_constraint
194 typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
195 #   define GNULIB_defined_verify_NSIG_constraint 1
196 #  endif
197
198 # endif
199
200 /* Test whether a given signal is contained in a signal set.  */
201 # if @HAVE_POSIX_SIGNALBLOCKING@
202 /* This function is defined as a macro on Mac OS X.  */
203 #  if defined __cplusplus && defined GNULIB_NAMESPACE
204 #   undef sigismember
205 #  endif
206 # else
207 _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
208                                     _GL_ARG_NONNULL ((1)));
209 # endif
210 _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig));
211 _GL_CXXALIASWARN (sigismember);
212
213 /* Initialize a signal set to the empty set.  */
214 # if @HAVE_POSIX_SIGNALBLOCKING@
215 /* This function is defined as a macro on Mac OS X.  */
216 #  if defined __cplusplus && defined GNULIB_NAMESPACE
217 #   undef sigemptyset
218 #  endif
219 # else
220 _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
221 # endif
222 _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set));
223 _GL_CXXALIASWARN (sigemptyset);
224
225 /* Add a signal to a signal set.  */
226 # if @HAVE_POSIX_SIGNALBLOCKING@
227 /* This function is defined as a macro on Mac OS X.  */
228 #  if defined __cplusplus && defined GNULIB_NAMESPACE
229 #   undef sigaddset
230 #  endif
231 # else
232 _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
233                                   _GL_ARG_NONNULL ((1)));
234 # endif
235 _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig));
236 _GL_CXXALIASWARN (sigaddset);
237
238 /* Remove a signal from a signal set.  */
239 # if @HAVE_POSIX_SIGNALBLOCKING@
240 /* This function is defined as a macro on Mac OS X.  */
241 #  if defined __cplusplus && defined GNULIB_NAMESPACE
242 #   undef sigdelset
243 #  endif
244 # else
245 _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
246                                   _GL_ARG_NONNULL ((1)));
247 # endif
248 _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig));
249 _GL_CXXALIASWARN (sigdelset);
250
251 /* Fill a signal set with all possible signals.  */
252 # if @HAVE_POSIX_SIGNALBLOCKING@
253 /* This function is defined as a macro on Mac OS X.  */
254 #  if defined __cplusplus && defined GNULIB_NAMESPACE
255 #   undef sigfillset
256 #  endif
257 # else
258 _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
259 # endif
260 _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set));
261 _GL_CXXALIASWARN (sigfillset);
262
263 /* Return the set of those blocked signals that are pending.  */
264 # if !@HAVE_POSIX_SIGNALBLOCKING@
265 _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
266 # endif
267 _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set));
268 _GL_CXXALIASWARN (sigpending);
269
270 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
271    Then, if SET is not NULL, affect the current set of blocked signals by
272    combining it with *SET as indicated in OPERATION.
273    In this implementation, you are not allowed to change a signal handler
274    while the signal is blocked.  */
275 # if !@HAVE_POSIX_SIGNALBLOCKING@
276 #  define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
277 #  define SIG_SETMASK 1  /* blocked_set = *set; */
278 #  define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
279 _GL_FUNCDECL_SYS (sigprocmask, int,
280                   (int operation, const sigset_t *set, sigset_t *old_set));
281 # endif
282 _GL_CXXALIAS_SYS (sigprocmask, int,
283                   (int operation, const sigset_t *set, sigset_t *old_set));
284 _GL_CXXALIASWARN (sigprocmask);
285
286 /* Install the handler FUNC for signal SIG, and return the previous
287    handler.  */
288 # ifdef __cplusplus
289 extern "C" {
290 # endif
291 # if !GNULIB_defined_function_taking_int_returning_void_t
292 typedef void (*_gl_function_taking_int_returning_void_t) (int);
293 #  define GNULIB_defined_function_taking_int_returning_void_t 1
294 # endif
295 # ifdef __cplusplus
296 }
297 # endif
298 # if !@HAVE_POSIX_SIGNALBLOCKING@
299 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
300 #   define signal rpl_signal
301 #  endif
302 _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t,
303                   (int sig, _gl_function_taking_int_returning_void_t func));
304 _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
305                   (int sig, _gl_function_taking_int_returning_void_t func));
306 # else
307 _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
308                   (int sig, _gl_function_taking_int_returning_void_t func));
309 # endif
310 _GL_CXXALIASWARN (signal);
311
312 # if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE
313 /* Raise signal SIGPIPE.  */
314 _GL_EXTERN_C int _gl_raise_SIGPIPE (void);
315 # endif
316
317 #elif defined GNULIB_POSIXCHECK
318 # undef sigaddset
319 # if HAVE_RAW_DECL_SIGADDSET
320 _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - "
321                  "use the gnulib module sigprocmask for portability");
322 # endif
323 # undef sigdelset
324 # if HAVE_RAW_DECL_SIGDELSET
325 _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - "
326                  "use the gnulib module sigprocmask for portability");
327 # endif
328 # undef sigemptyset
329 # if HAVE_RAW_DECL_SIGEMPTYSET
330 _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - "
331                  "use the gnulib module sigprocmask for portability");
332 # endif
333 # undef sigfillset
334 # if HAVE_RAW_DECL_SIGFILLSET
335 _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - "
336                  "use the gnulib module sigprocmask for portability");
337 # endif
338 # undef sigismember
339 # if HAVE_RAW_DECL_SIGISMEMBER
340 _GL_WARN_ON_USE (sigismember, "sigismember is unportable - "
341                  "use the gnulib module sigprocmask for portability");
342 # endif
343 # undef sigpending
344 # if HAVE_RAW_DECL_SIGPENDING
345 _GL_WARN_ON_USE (sigpending, "sigpending is unportable - "
346                  "use the gnulib module sigprocmask for portability");
347 # endif
348 # undef sigprocmask
349 # if HAVE_RAW_DECL_SIGPROCMASK
350 _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - "
351                  "use the gnulib module sigprocmask for portability");
352 # endif
353 #endif /* @GNULIB_SIGPROCMASK@ */
354
355
356 #if @GNULIB_SIGACTION@
357 # if !@HAVE_SIGACTION@
358
359 #  if !@HAVE_SIGINFO_T@
360
361 #   if !GNULIB_defined_siginfo_types
362
363 /* Present to allow compilation, but unsupported by gnulib.  */
364 union sigval
365 {
366   int sival_int;
367   void *sival_ptr;
368 };
369
370 /* Present to allow compilation, but unsupported by gnulib.  */
371 struct siginfo_t
372 {
373   int si_signo;
374   int si_code;
375   int si_errno;
376   pid_t si_pid;
377   uid_t si_uid;
378   void *si_addr;
379   int si_status;
380   long si_band;
381   union sigval si_value;
382 };
383 typedef struct siginfo_t siginfo_t;
384
385 #    define GNULIB_defined_siginfo_types 1
386 #   endif
387
388 #  endif /* !@HAVE_SIGINFO_T@ */
389
390 /* We assume that platforms which lack the sigaction() function also lack
391    the 'struct sigaction' type, and vice versa.  */
392
393 #  if !GNULIB_defined_struct_sigaction
394
395 struct sigaction
396 {
397   union
398   {
399     void (*_sa_handler) (int);
400     /* Present to allow compilation, but unsupported by gnulib.  POSIX
401        says that implementations may, but not must, make sa_sigaction
402        overlap with sa_handler, but we know of no implementation where
403        they do not overlap.  */
404     void (*_sa_sigaction) (int, siginfo_t *, void *);
405   } _sa_func;
406   sigset_t sa_mask;
407   /* Not all POSIX flags are supported.  */
408   int sa_flags;
409 };
410 #   define sa_handler _sa_func._sa_handler
411 #   define sa_sigaction _sa_func._sa_sigaction
412 /* Unsupported flags are not present.  */
413 #   define SA_RESETHAND 1
414 #   define SA_NODEFER 2
415 #   define SA_RESTART 4
416
417 #   define GNULIB_defined_struct_sigaction 1
418 #  endif
419
420 _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
421                                    struct sigaction *restrict));
422
423 # elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
424
425 #  define sa_sigaction sa_handler
426
427 # endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
428
429 _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict,
430                                    struct sigaction *restrict));
431 _GL_CXXALIASWARN (sigaction);
432
433 #elif defined GNULIB_POSIXCHECK
434 # undef sigaction
435 # if HAVE_RAW_DECL_SIGACTION
436 _GL_WARN_ON_USE (sigaction, "sigaction is unportable - "
437                  "use the gnulib module sigaction for portability");
438 # endif
439 #endif
440
441 /* Some systems don't have SA_NODEFER.  */
442 #ifndef SA_NODEFER
443 # define SA_NODEFER 0
444 #endif
445
446
447 #endif /* _@GUARD_PREFIX@_SIGNAL_H */
448 #endif /* _@GUARD_PREFIX@_SIGNAL_H */
449 #endif