eb16afb2717db6918a866e155eb70de338b71d15
[gnulib.git] / lib / signal.in.h
1 /* A GNU-like <signal.h>.
2
3    Copyright (C) 2006-2008 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 <http://www.gnu.org/licenses/>.  */
17
18 #if defined __need_sig_atomic_t || defined __need_sigset_t
19 /* Special invocation convention inside glibc header files.  */
20
21 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
22
23 #else
24 /* Normal invocation convention.  */
25
26 #ifndef _GL_SIGNAL_H
27
28 /* The include_next requires a split double-inclusion guard.  */
29 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
30
31 #ifndef _GL_SIGNAL_H
32 #define _GL_SIGNAL_H
33
34 /* The definition of GL_LINK_WARNING is copied here.  */
35
36 /* Mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
37 #if !@HAVE_POSIX_SIGNALBLOCKING@
38 # include <sys/types.h>
39 #endif
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45
46 #if !@HAVE_POSIX_SIGNALBLOCKING@
47
48 /* Maximum signal number + 1.  */
49 # ifndef NSIG
50 #  define NSIG 32
51 # endif
52
53 /* This code supports only 32 signals.  */
54 typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1];
55
56 /* A set or mask of signals.  */
57 # if !@HAVE_SIGSET_T@
58 typedef unsigned int sigset_t;
59 # endif
60
61 /* Test whether a given signal is contained in a signal set.  */
62 extern int sigismember (const sigset_t *set, int sig);
63
64 /* Initialize a signal set to the empty set.  */
65 extern int sigemptyset (sigset_t *set);
66
67 /* Add a signal to a signal set.  */
68 extern int sigaddset (sigset_t *set, int sig);
69
70 /* Remove a signal from a signal set.  */
71 extern int sigdelset (sigset_t *set, int sig);
72
73 /* Fill a signal set with all possible signals.  */
74 extern int sigfillset (sigset_t *set);
75
76 /* Return the set of those blocked signals that are pending.  */
77 extern int sigpending (sigset_t *set);
78
79 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
80    Then, if SET is not NULL, affect the current set of blocked signals by
81    combining it with *SET as indicated in OPERATION.
82    In this implementation, you are not allowed to change a signal handler
83    while the signal is blocked.  */
84 # define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
85 # define SIG_SETMASK 1  /* blocked_set = *set; */
86 # define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
87 extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
88
89 # define signal rpl_signal
90 /* Install the handler FUNC for signal SIG, and return the previous
91    handler.  */
92 extern void (*signal (int sig, void (*func) (int))) (int);
93
94 #endif
95
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #endif /* _GL_SIGNAL_H */
102 #endif /* _GL_SIGNAL_H */
103 #endif