Tests for module 'unicase/u8-is-uppercase'.
[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 __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21
22 #if defined __need_sig_atomic_t || defined __need_sigset_t
23 /* Special invocation convention inside glibc header files.  */
24
25 # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@
26
27 #else
28 /* Normal invocation convention.  */
29
30 #ifndef _GL_SIGNAL_H
31
32 /* The include_next requires a split double-inclusion guard.  */
33 #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@
34
35 #ifndef _GL_SIGNAL_H
36 #define _GL_SIGNAL_H
37
38 /* The definition of GL_LINK_WARNING is copied here.  */
39
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>
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48
49 #if @GNULIB_SIGNAL_H_SIGPIPE@
50 # ifndef SIGPIPE
51 /* Define SIGPIPE to a value that does not overlap with other signals.  */
52 #  define SIGPIPE 13
53 #  define GNULIB_defined_SIGPIPE 1
54 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask',
55    'write', 'stdio'.  */
56 # endif
57 #endif
58
59
60 #if !@HAVE_POSIX_SIGNALBLOCKING@
61
62 /* Maximum signal number + 1.  */
63 # ifndef NSIG
64 #  define NSIG 32
65 # endif
66
67 /* This code supports only 32 signals.  */
68 typedef int verify_NSIG_constraint[2 * (NSIG <= 32) - 1];
69
70 /* A set or mask of signals.  */
71 # if !@HAVE_SIGSET_T@
72 typedef unsigned int sigset_t;
73 # endif
74
75 /* Test whether a given signal is contained in a signal set.  */
76 extern int sigismember (const sigset_t *set, int sig);
77
78 /* Initialize a signal set to the empty set.  */
79 extern int sigemptyset (sigset_t *set);
80
81 /* Add a signal to a signal set.  */
82 extern int sigaddset (sigset_t *set, int sig);
83
84 /* Remove a signal from a signal set.  */
85 extern int sigdelset (sigset_t *set, int sig);
86
87 /* Fill a signal set with all possible signals.  */
88 extern int sigfillset (sigset_t *set);
89
90 /* Return the set of those blocked signals that are pending.  */
91 extern int sigpending (sigset_t *set);
92
93 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
94    Then, if SET is not NULL, affect the current set of blocked signals by
95    combining it with *SET as indicated in OPERATION.
96    In this implementation, you are not allowed to change a signal handler
97    while the signal is blocked.  */
98 # define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
99 # define SIG_SETMASK 1  /* blocked_set = *set; */
100 # define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
101 extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
102
103 # define signal rpl_signal
104 /* Install the handler FUNC for signal SIG, and return the previous
105    handler.  */
106 extern void (*signal (int sig, void (*func) (int))) (int);
107
108 # if GNULIB_defined_SIGPIPE
109
110 /* Raise signal SIG.  */
111 #  undef raise
112 #  define raise rpl_raise
113 extern int raise (int sig);
114
115 # endif
116
117 #endif /* !@HAVE_POSIX_SIGNALBLOCKING@ */
118
119
120 #if !@HAVE_SIGACTION@
121
122 # if !@HAVE_SIGINFO_T@
123 /* Present to allow compilation, but unsupported by gnulib.  */
124 union sigval
125 {
126   int sival_int;
127   void *sival_ptr;
128 };
129
130 /* Present to allow compilation, but unsupported by gnulib.  */
131 struct siginfo_t
132 {
133   int si_signo;
134   int si_code;
135   int si_errno;
136   pid_t si_pid;
137   uid_t si_uid;
138   void *si_addr;
139   int si_status;
140   long si_band;
141   union sigval si_value;
142 };
143 typedef struct siginfo_t siginfo_t;
144 # endif /* !@HAVE_SIGINFO_T@ */
145
146 /* We assume that platforms which lack the sigaction() function also lack
147    the 'struct sigaction' type, and vice versa.  */
148
149 struct sigaction
150 {
151   union
152   {
153     void (*_sa_handler) (int);
154     /* Present to allow compilation, but unsupported by gnulib.  POSIX
155        says that implementations may, but not must, make sa_sigaction
156        overlap with sa_handler, but we know of no implementation where
157        they do not overlap.  */
158     void (*_sa_sigaction) (int, siginfo_t *, void *);
159   } _sa_func;
160   sigset_t sa_mask;
161   /* Not all POSIX flags are supported.  */
162   int sa_flags;
163 };
164 # define sa_handler _sa_func._sa_handler
165 # define sa_sigaction _sa_func._sa_sigaction
166 /* Unsupported flags are not present.  */
167 # define SA_RESETHAND 1
168 # define SA_NODEFER 2
169 # define SA_RESTART 4
170
171 extern int sigaction (int, const struct sigaction *restrict,
172                       struct sigaction *restrict);
173
174 #elif !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@
175
176 # define sa_sigaction sa_handler
177
178 #endif /* !@HAVE_SIGACTION@, !@HAVE_STRUCT_SIGACTION_SA_SIGACTION@ */
179
180
181 /* Some systems don't have SA_NODEFER.  */
182 #ifndef SA_NODEFER
183 # define SA_NODEFER 0
184 #endif
185
186
187 #ifdef __cplusplus
188 }
189 #endif
190
191 #endif /* _GL_SIGNAL_H */
192 #endif /* _GL_SIGNAL_H */
193 #endif