1 /* A GNU-like <signal.h>.
3 Copyright (C) 2006-2008 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/>. */
18 @PRAGMA_SYSTEM_HEADER@
20 #if defined __need_sig_atomic_t || defined __need_sigset_t
21 /* Special invocation convention inside glibc header files. */
23 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
26 /* Normal invocation convention. */
30 /* The include_next requires a split double-inclusion guard. */
31 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
36 /* The definition of GL_LINK_WARNING is copied here. */
38 /* Define pid_t, uid_t.
39 Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. */
40 #include <sys/types.h>
47 #if @GNULIB_SIGNAL_H_SIGPIPE@
49 /* Define SIGPIPE to a value that does not overlap with other signals. */
51 # define GNULIB_defined_SIGPIPE 1
52 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
58 #if !@HAVE_POSIX_SIGNALBLOCKING@
60 /* Maximum signal number + 1. */
65 /* This code supports only 32 signals. */
66 typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1];
68 /* A set or mask of signals. */
70 typedef unsigned int sigset_t;
73 /* Test whether a given signal is contained in a signal set. */
74 extern int sigismember (const sigset_t *set, int sig);
76 /* Initialize a signal set to the empty set. */
77 extern int sigemptyset (sigset_t *set);
79 /* Add a signal to a signal set. */
80 extern int sigaddset (sigset_t *set, int sig);
82 /* Remove a signal from a signal set. */
83 extern int sigdelset (sigset_t *set, int sig);
85 /* Fill a signal set with all possible signals. */
86 extern int sigfillset (sigset_t *set);
88 /* Return the set of those blocked signals that are pending. */
89 extern int sigpending (sigset_t *set);
91 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
92 Then, if SET is not NULL, affect the current set of blocked signals by
93 combining it with *SET as indicated in OPERATION.
94 In this implementation, you are not allowed to change a signal handler
95 while the signal is blocked. */
96 # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */
97 # define SIG_SETMASK 1 /* blocked_set = *set; */
98 # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */
99 extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
101 # define signal rpl_signal
102 /* Install the handler FUNC for signal SIG, and return the previous
104 extern void (*signal (int sig, void (*func) (int))) (int);
106 # if GNULIB_defined_SIGPIPE
108 /* Raise signal SIG. */
110 # define raise rpl_raise
111 extern int raise (int sig);
115 #endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */
118 #if !@HAVE_SIGACTION@
120 # if !@HAVE_SIGINFO_T@
121 /* Present to allow compilation, but unsupported by gnulib. */
128 /* Present to allow compilation, but unsupported by gnulib. */
139 union sigval si_value;
141 typedef struct siginfo_t siginfo_t;
142 # endif /* !@HAVE_SIGINFO_T@ */
144 /* We assume that platforms which lack the sigaction() function also lack
145 the 'struct sigaction' type, and vice versa. */
151 void (*_sa_handler) (int);
152 /* Present to allow compilation, but unsupported by gnulib. POSIX
153 says that implementations may, but not must, make sa_sigaction
154 overlap with sa_handler, but we know of no implementation where
155 they do not overlap. */
156 void (*_sa_sigaction) (int, siginfo_t *, void *);
159 /* Not all POSIX flags are supported. */
162 # define sa_handler _sa_func._sa_handler
163 # define sa_sigaction _sa_func._sa_sigaction
164 /* Unsupported flags are not present. */
165 # define SA_RESETHAND 1
166 # define SA_NODEFER 2
167 # define SA_RESTART 4
169 extern int sigaction (int, const struct sigaction *restrict,
170 struct sigaction *restrict);
172 #elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
174 # define sa_sigaction sa_handler
176 #endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
183 #endif /* _GL_SIGNAL_H */
184 #endif /* _GL_SIGNAL_H */