1 /* A GNU-like <signal.h>.
3 Copyright (C) 2006-2009 Free Software Foundation, Inc.
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 @PRAGMA_SYSTEM_HEADER@
22 #if defined __need_sig_atomic_t || defined __need_sigset_t
23 /* Special invocation convention inside glibc header files. */
25 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
28 /* Normal invocation convention. */
32 /* The include_next requires a split double-inclusion guard. */
33 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
38 /* The definition of GL_LINK_WARNING is copied here. */
40 /* Define pid_t, uid_t.
41 Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. */
42 #include <sys/types.h>
44 /* On AIX, sig_atomic_t already includes volatile. C99 requires that
45 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
46 Hence, redefine this to a non-volatile type as needed. */
47 #if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
48 typedef int rpl_sig_atomic_t;
50 # define sig_atomic_t rpl_sig_atomic_t
58 #if @GNULIB_SIGNAL_H_SIGPIPE@
60 /* Define SIGPIPE to a value that does not overlap with other signals. */
62 # define GNULIB_defined_SIGPIPE 1
63 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
69 #if !@HAVE_POSIX_SIGNALBLOCKING@
71 /* Maximum signal number + 1. */
76 /* This code supports only 32 signals. */
77 typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1];
79 /* A set or mask of signals. */
81 typedef unsigned int sigset_t;
84 /* Test whether a given signal is contained in a signal set. */
85 extern int sigismember (const sigset_t *set, int sig);
87 /* Initialize a signal set to the empty set. */
88 extern int sigemptyset (sigset_t *set);
90 /* Add a signal to a signal set. */
91 extern int sigaddset (sigset_t *set, int sig);
93 /* Remove a signal from a signal set. */
94 extern int sigdelset (sigset_t *set, int sig);
96 /* Fill a signal set with all possible signals. */
97 extern int sigfillset (sigset_t *set);
99 /* Return the set of those blocked signals that are pending. */
100 extern int sigpending (sigset_t *set);
102 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
103 Then, if SET is not NULL, affect the current set of blocked signals by
104 combining it with *SET as indicated in OPERATION.
105 In this implementation, you are not allowed to change a signal handler
106 while the signal is blocked. */
107 # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */
108 # define SIG_SETMASK 1 /* blocked_set = *set; */
109 # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */
110 extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
112 # define signal rpl_signal
113 /* Install the handler FUNC for signal SIG, and return the previous
115 extern void (*signal (int sig, void (*func) (int))) (int);
117 # if GNULIB_defined_SIGPIPE
119 /* Raise signal SIG. */
121 # define raise rpl_raise
122 extern int raise (int sig);
126 #endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */
129 #if !@HAVE_SIGACTION@
131 # if !@HAVE_SIGINFO_T@
132 /* Present to allow compilation, but unsupported by gnulib. */
139 /* Present to allow compilation, but unsupported by gnulib. */
150 union sigval si_value;
152 typedef struct siginfo_t siginfo_t;
153 # endif /* !@HAVE_SIGINFO_T@ */
155 /* We assume that platforms which lack the sigaction() function also lack
156 the 'struct sigaction' type, and vice versa. */
162 void (*_sa_handler) (int);
163 /* Present to allow compilation, but unsupported by gnulib. POSIX
164 says that implementations may, but not must, make sa_sigaction
165 overlap with sa_handler, but we know of no implementation where
166 they do not overlap. */
167 void (*_sa_sigaction) (int, siginfo_t *, void *);
170 /* Not all POSIX flags are supported. */
173 # define sa_handler _sa_func._sa_handler
174 # define sa_sigaction _sa_func._sa_sigaction
175 /* Unsupported flags are not present. */
176 # define SA_RESETHAND 1
177 # define SA_NODEFER 2
178 # define SA_RESTART 4
180 extern int sigaction (int, const struct sigaction *restrict,
181 struct sigaction *restrict);
183 #elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
185 # define sa_sigaction sa_handler
187 #endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
190 /* Some systems don't have SA_NODEFER. */
192 # define SA_NODEFER 0
200 #endif /* _GL_SIGNAL_H */
201 #endif /* _GL_SIGNAL_H */