soft-fp: Use __label__ for all labels within macros.
[glibc.git] / signal / signal.h
blobc32e8d961b13cb1fe18342bf458018e29a1399ad
1 /* Copyright (C) 1991-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.14 Signal handling <signal.h>
22 #ifndef _SIGNAL_H
24 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
25 # define _SIGNAL_H
26 #endif
28 #include <features.h>
30 __BEGIN_DECLS
32 #include <bits/sigset.h> /* __sigset_t, __sig_atomic_t. */
34 /* An integral type that can be modified atomically, without the
35 possibility of a signal arriving in the middle of the operation. */
36 #if defined __need_sig_atomic_t || defined _SIGNAL_H
37 # ifndef __sig_atomic_t_defined
38 # define __sig_atomic_t_defined
39 __BEGIN_NAMESPACE_STD
40 typedef __sig_atomic_t sig_atomic_t;
41 __END_NAMESPACE_STD
42 # endif
43 # undef __need_sig_atomic_t
44 #endif
46 #if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)
47 # ifndef __sigset_t_defined
48 # define __sigset_t_defined
49 typedef __sigset_t sigset_t;
50 # endif
51 # undef __need_sigset_t
52 #endif
54 #ifdef _SIGNAL_H
56 #include <bits/types.h>
57 #include <bits/signum.h>
59 #if defined __USE_XOPEN || defined __USE_XOPEN2K
60 # ifndef __pid_t_defined
61 typedef __pid_t pid_t;
62 # define __pid_t_defined
63 #endif
64 #ifdef __USE_XOPEN
65 # endif
66 # ifndef __uid_t_defined
67 typedef __uid_t uid_t;
68 # define __uid_t_defined
69 # endif
70 #endif /* Unix98 */
72 #ifdef __USE_POSIX199309
73 /* We need `struct timespec' later on. */
74 # define __need_timespec
75 # include <time.h>
76 #endif
78 #if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
79 /* Get the `siginfo_t' type plus the needed symbols. */
80 # include <bits/siginfo.h>
81 #endif
84 /* Type of a signal handler. */
85 typedef void (*__sighandler_t) (int);
87 /* The X/Open definition of `signal' specifies the SVID semantic. Use
88 the additional function `sysv_signal' when X/Open compatibility is
89 requested. */
90 extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
91 __THROW;
92 #ifdef __USE_GNU
93 extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
94 __THROW;
95 #endif
97 /* Set the handler for the signal SIG to HANDLER, returning the old
98 handler, or SIG_ERR on error.
99 By default `signal' has the BSD semantic. */
100 __BEGIN_NAMESPACE_STD
101 #ifdef __USE_MISC
102 extern __sighandler_t signal (int __sig, __sighandler_t __handler)
103 __THROW;
104 #else
105 /* Make sure the used `signal' implementation is the SVID version. */
106 # ifdef __REDIRECT_NTH
107 extern __sighandler_t __REDIRECT_NTH (signal,
108 (int __sig, __sighandler_t __handler),
109 __sysv_signal);
110 # else
111 # define signal __sysv_signal
112 # endif
113 #endif
114 __END_NAMESPACE_STD
116 #ifdef __USE_XOPEN
117 /* The X/Open definition of `signal' conflicts with the BSD version.
118 So they defined another function `bsd_signal'. */
119 extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
120 __THROW;
121 #endif
123 /* Send signal SIG to process number PID. If PID is zero,
124 send SIG to all processes in the current process's process group.
125 If PID is < -1, send SIG to all processes in process group - PID. */
126 #ifdef __USE_POSIX
127 extern int kill (__pid_t __pid, int __sig) __THROW;
128 #endif /* Use POSIX. */
130 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
131 /* Send SIG to all processes in process group PGRP.
132 If PGRP is zero, send SIG to all processes in
133 the current process's process group. */
134 extern int killpg (__pid_t __pgrp, int __sig) __THROW;
135 #endif /* Use misc || X/Open Unix. */
137 __BEGIN_NAMESPACE_STD
138 /* Raise signal SIG, i.e., send SIG to yourself. */
139 extern int raise (int __sig) __THROW;
140 __END_NAMESPACE_STD
142 #ifdef __USE_MISC
143 /* SVID names for the same things. */
144 extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
145 __THROW;
146 extern int gsignal (int __sig) __THROW;
147 #endif /* Use misc. */
149 #ifdef __USE_XOPEN2K
150 /* Print a message describing the meaning of the given signal number. */
151 extern void psignal (int __sig, const char *__s);
152 #endif /* Use POSIX 2008. */
154 #ifdef __USE_XOPEN2K
155 /* Print a message describing the meaning of the given signal information. */
156 extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
157 #endif /* POSIX 2008. */
161 /* The `sigpause' function in X/Open defines the argument as the
162 signal number. This requires redirecting to another function
163 because the default version in glibc uses an old BSD interface.
165 This function is a cancellation point and therefore not marked with
166 __THROW. */
168 #ifdef __USE_XOPEN
169 # ifdef __GNUC__
170 extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
171 # else
172 extern int __sigpause (int __sig_or_mask, int __is_sig);
173 /* Remove a signal from the signal mask and suspend the process. */
174 # define sigpause(sig) __sigpause ((sig), 1)
175 # endif
176 #endif
179 #ifdef __USE_MISC
180 /* None of the following functions should be used anymore. They are here
181 only for compatibility. A single word (`int') is not guaranteed to be
182 enough to hold a complete signal mask and therefore these functions
183 simply do not work in many situations. Use `sigprocmask' instead. */
185 /* Compute mask for signal SIG. */
186 # define sigmask(sig) __sigmask(sig)
188 /* Block signals in MASK, returning the old mask. */
189 extern int sigblock (int __mask) __THROW __attribute_deprecated__;
191 /* Set the mask of blocked signals to MASK, returning the old mask. */
192 extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
194 /* Return currently selected signal mask. */
195 extern int siggetmask (void) __THROW __attribute_deprecated__;
196 #endif /* Use misc. */
199 #ifdef __USE_MISC
200 # define NSIG _NSIG
201 #endif
203 #ifdef __USE_GNU
204 typedef __sighandler_t sighandler_t;
205 #endif
207 /* 4.4 BSD uses the name `sig_t' for this. */
208 #ifdef __USE_MISC
209 typedef __sighandler_t sig_t;
210 #endif
212 #ifdef __USE_POSIX
214 /* Clear all signals from SET. */
215 extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
217 /* Set all signals in SET. */
218 extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
220 /* Add SIGNO to SET. */
221 extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
223 /* Remove SIGNO from SET. */
224 extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
226 /* Return 1 if SIGNO is in SET, 0 if not. */
227 extern int sigismember (const sigset_t *__set, int __signo)
228 __THROW __nonnull ((1));
230 # ifdef __USE_GNU
231 /* Return non-empty value is SET is not empty. */
232 extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1));
234 /* Build new signal set by combining the two inputs set using logical AND. */
235 extern int sigandset (sigset_t *__set, const sigset_t *__left,
236 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
238 /* Build new signal set by combining the two inputs set using logical OR. */
239 extern int sigorset (sigset_t *__set, const sigset_t *__left,
240 const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
241 # endif /* GNU */
243 /* Get the system-specific definitions of `struct sigaction'
244 and the `SA_*' and `SIG_*'. constants. */
245 # include <bits/sigaction.h>
247 /* Get and/or change the set of blocked signals. */
248 extern int sigprocmask (int __how, const sigset_t *__restrict __set,
249 sigset_t *__restrict __oset) __THROW;
251 /* Change the set of blocked signals to SET,
252 wait until a signal arrives, and restore the set of blocked signals.
254 This function is a cancellation point and therefore not marked with
255 __THROW. */
256 extern int sigsuspend (const sigset_t *__set) __nonnull ((1));
258 /* Get and/or set the action for signal SIG. */
259 extern int sigaction (int __sig, const struct sigaction *__restrict __act,
260 struct sigaction *__restrict __oact) __THROW;
262 /* Put in SET all signals that are blocked and waiting to be delivered. */
263 extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
266 /* Select any of pending signals from SET or wait for any to arrive.
268 This function is a cancellation point and therefore not marked with
269 __THROW. */
270 extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
271 __nonnull ((1, 2));
273 # ifdef __USE_POSIX199309
274 /* Select any of pending signals from SET and place information in INFO.
276 This function is a cancellation point and therefore not marked with
277 __THROW. */
278 extern int sigwaitinfo (const sigset_t *__restrict __set,
279 siginfo_t *__restrict __info) __nonnull ((1));
281 /* Select any of pending signals from SET and place information in INFO.
282 Wait the time specified by TIMEOUT if no signal is pending.
284 This function is a cancellation point and therefore not marked with
285 __THROW. */
286 extern int sigtimedwait (const sigset_t *__restrict __set,
287 siginfo_t *__restrict __info,
288 const struct timespec *__restrict __timeout)
289 __nonnull ((1));
291 /* Send signal SIG to the process PID. Associate data in VAL with the
292 signal. */
293 extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
294 __THROW;
295 # endif /* Use POSIX 199306. */
297 #endif /* Use POSIX. */
299 #ifdef __USE_MISC
301 /* Names of the signals. This variable exists only for compatibility.
302 Use `strsignal' instead (see <string.h>). */
303 extern const char *const _sys_siglist[_NSIG];
304 extern const char *const sys_siglist[_NSIG];
307 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
308 # include <bits/sigcontext.h>
310 /* Restore the state saved in SCP. */
311 extern int sigreturn (struct sigcontext *__scp) __THROW;
313 #endif /* Use misc. */
316 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
317 # define __need_size_t
318 # include <stddef.h>
320 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
321 (causing them to fail with EINTR); if INTERRUPT is zero, make system
322 calls be restarted after signal SIG. */
323 extern int siginterrupt (int __sig, int __interrupt) __THROW;
325 # include <bits/sigstack.h>
326 # if defined __USE_XOPEN || defined __USE_XOPEN2K8
327 /* This will define `ucontext_t' and `mcontext_t'. */
328 # include <sys/ucontext.h>
329 # endif
331 /* Run signals handlers on the stack specified by SS (if not NULL).
332 If OSS is not NULL, it is filled in with the old signal stack status.
333 This interface is obsolete and on many platform not implemented. */
334 extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
335 __THROW __attribute_deprecated__;
337 /* Alternate signal handler stack interface.
338 This interface should always be preferred over `sigstack'. */
339 extern int sigaltstack (const struct sigaltstack *__restrict __ss,
340 struct sigaltstack *__restrict __oss) __THROW;
342 #endif /* Use POSIX.1-2008 or X/Open Unix. */
344 #ifdef __USE_XOPEN_EXTENDED
345 /* Simplified interface for signal management. */
347 /* Add SIG to the calling process' signal mask. */
348 extern int sighold (int __sig) __THROW;
350 /* Remove SIG from the calling process' signal mask. */
351 extern int sigrelse (int __sig) __THROW;
353 /* Set the disposition of SIG to SIG_IGN. */
354 extern int sigignore (int __sig) __THROW;
356 /* Set the disposition of SIG. */
357 extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
358 #endif
360 #if defined __USE_POSIX199506 || defined __USE_UNIX98
361 /* Some of the functions for handling signals in threaded programs must
362 be defined here. */
363 # include <bits/pthreadtypes.h>
364 # include <bits/sigthread.h>
365 #endif /* use Unix98 */
367 /* The following functions are used internally in the C library and in
368 other code which need deep insights. */
370 /* Return number of available real-time signal with highest priority. */
371 extern int __libc_current_sigrtmin (void) __THROW;
372 /* Return number of available real-time signal with lowest priority. */
373 extern int __libc_current_sigrtmax (void) __THROW;
375 #endif /* signal.h */
377 __END_DECLS
379 #endif /* not signal.h */