]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/include/signal.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / include / signal.h
1 /* Copyright (C) 1991-2003, 2004, 2007, 2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.  */
17
18 /*
19  *      ISO C99 Standard: 7.14 Signal handling <signal.h>
20  */
21
22 #ifndef _SIGNAL_H
23
24 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
25 # define _SIGNAL_H
26 #endif
27
28 #include <features.h>
29
30 __BEGIN_DECLS
31
32 #include <bits/sigset.h>                /* __sigset_t, __sig_atomic_t.  */
33
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
45
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
53
54 #ifdef _SIGNAL_H
55
56 #include <bits/types.h>
57 #include <bits/signum.h>
58
59 /* Fake signal functions.  */
60 #define SIG_ERR    ((__sighandler_t) -1) /* Error return.  */
61 #define SIG_DFL    ((__sighandler_t) 0)  /* Default action.  */
62 #define SIG_IGN    ((__sighandler_t) 1)  /* Ignore signal.  */
63 #ifdef __USE_UNIX98
64 # define SIG_HOLD  ((__sighandler_t) 2)  /* Add signal to hold mask.  */
65 #endif
66 /* Biggest signal number + 1 (including real-time signals).  */
67 #ifndef _NSIG /* if arch has not defined it in bits/signum.h... */
68 # define _NSIG 65
69 #endif
70 #ifdef __USE_MISC
71 # define NSIG _NSIG
72 #endif
73 /* Real-time signal range */
74 #define SIGRTMIN   (__libc_current_sigrtmin())
75 #define SIGRTMAX   (__libc_current_sigrtmax())
76 /* These are the hard limits of the kernel.  These values should not be
77    used directly at user level.  */
78 #ifndef __SIGRTMIN /* if arch has not defined it in bits/signum.h... */
79 # define __SIGRTMIN 32
80 #endif
81 #define __SIGRTMAX (_NSIG - 1)
82
83
84 #if defined __USE_XOPEN || defined __USE_XOPEN2K
85 # ifndef __pid_t_defined
86 typedef __pid_t pid_t;
87 #  define __pid_t_defined
88 # endif
89 #endif
90 #ifdef __USE_XOPEN
91 # ifndef __uid_t_defined
92 typedef __uid_t uid_t;
93 #  define __uid_t_defined
94 # endif
95 #endif  /* Unix98 */
96
97 #if defined __USE_POSIX199309 && defined __UCLIBC_HAS_REALTIME__
98 /* We need `struct timespec' later on.  */
99 # define __need_timespec
100 # include <time.h>
101
102 /* Get the `siginfo_t' type plus the needed symbols.  */
103 # include <bits/siginfo.h>
104 #endif
105
106
107 /* Type of a signal handler.  */
108 typedef void (*__sighandler_t) (int);
109
110 #if defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
111 /* The X/Open definition of `signal' specifies the SVID semantic.  Use
112    the additional function `sysv_signal' when X/Open compatibility is
113    requested.  */
114 extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
115      __THROW;
116 # ifdef __USE_GNU
117 extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
118      __THROW;
119 # endif
120 #endif /* __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__ */
121
122 /* Set the handler for the signal SIG to HANDLER, returning the old
123    handler, or SIG_ERR on error.
124    By default `signal' has the BSD semantic.  */
125 __BEGIN_NAMESPACE_STD
126 #if defined __USE_BSD || !defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
127 extern __sighandler_t signal (int __sig, __sighandler_t __handler)
128      __THROW;
129 libc_hidden_proto(signal)
130 #else
131 /* Make sure the used `signal' implementation is the SVID version. */
132 # ifdef __REDIRECT_NTH
133 extern __sighandler_t __REDIRECT_NTH (signal,
134                                       (int __sig, __sighandler_t __handler),
135                                       __sysv_signal);
136 # else
137 #  define signal __sysv_signal
138 # endif
139 #endif
140 __END_NAMESPACE_STD
141
142 #if defined __USE_XOPEN && defined __UCLIBC_SUSV3_LEGACY__
143 /* The X/Open definition of `signal' conflicts with the BSD version.
144    So they defined another function `bsd_signal'.  */
145 extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
146      __THROW;
147 #endif
148
149 /* Send signal SIG to process number PID.  If PID is zero,
150    send SIG to all processes in the current process's process group.
151    If PID is < -1, send SIG to all processes in process group - PID.  */
152 #ifdef __USE_POSIX
153 extern int kill (__pid_t __pid, int __sig) __THROW;
154 libc_hidden_proto(kill)
155 #endif
156
157 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
158 /* Send SIG to all processes in process group PGRP.
159    If PGRP is zero, send SIG to all processes in
160    the current process's process group.  */
161 extern int killpg (__pid_t __pgrp, int __sig) __THROW;
162 #endif
163
164 __BEGIN_NAMESPACE_STD
165 /* Raise signal SIG, i.e., send SIG to yourself.  */
166 extern int raise (int __sig) __THROW;
167 libc_hidden_proto(raise)
168 __END_NAMESPACE_STD
169
170 #if 0 /*def __USE_SVID*/
171 /* SVID names for the same things.  */
172 extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
173      __THROW;
174 extern int gsignal (int __sig) __THROW;
175 #endif /* Use SVID.  */
176
177 /* glibc guards the next two wrong with __USE_XOPEN2K */
178 #if defined __USE_MISC || defined __USE_XOPEN2K8
179 /* Print a message describing the meaning of the given signal number.  */
180 extern void psignal (int __sig, const char *__s);
181 #endif /* Use misc or POSIX 2008.  */
182
183 #if 0 /*def __USE_XOPEN2K8*/
184 /* Print a message describing the meaning of the given signal information.  */
185 extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
186 #endif /* POSIX 2008.  */
187
188 #ifdef __UCLIBC_SUSV4_LEGACY__
189 /* The `sigpause' function has two different interfaces.  The original
190    BSD definition defines the argument as a mask of the signal, while
191    the more modern interface in X/Open defines it as the signal
192    number.  We go with the BSD version unless the user explicitly
193    selects the X/Open version.
194
195    This function is a cancellation point and therefore not marked with
196    __THROW.  */
197 /*extern int __sigpause (int __sig_or_mask, int __is_sig);*/
198
199 #ifdef __FAVOR_BSD
200 /* Set the mask of blocked signals to MASK,
201    wait for a signal to arrive, and then restore the mask.  */
202 /*extern int sigpause (int __mask) __THROW __attribute_deprecated__;
203 # define sigpause(mask) __sigpause ((mask), 0)*/
204 /* uClibc note: BSD sigpause is available as __bsd_sigpause.
205  * It is intentionally not prototyped */
206 #else
207 # ifdef __USE_XOPEN
208 /* Remove a signal from the signal mask and suspend the process.  */
209 extern int sigpause(int __sig);
210 /*#  define sigpause(sig) __sigpause ((sig), 1)*/
211 # endif
212 #endif
213 #endif /* __UCLIBC_SUSV4_LEGACY__ */
214
215 #if 0 /*def __USE_BSD*/
216 /* None of the following functions should be used anymore.  They are here
217    only for compatibility.  A single word (`int') is not guaranteed to be
218    enough to hold a complete signal mask and therefore these functions
219    simply do not work in many situations.  Use `sigprocmask' instead.  */
220
221 /* Compute mask for signal SIG.  */
222 # define sigmask(sig)   __sigmask(sig)
223
224 /* Block signals in MASK, returning the old mask.  */
225 extern int sigblock (int __mask) __THROW __attribute_deprecated__;
226
227 /* Set the mask of blocked signals to MASK, returning the old mask.  */
228 extern int sigsetmask (int __mask) __THROW __attribute_deprecated__;
229
230 /* Return currently selected signal mask.  */
231 extern int siggetmask (void) __THROW __attribute_deprecated__;
232 #endif /* Use BSD.  */
233
234
235 #ifdef __USE_GNU
236 typedef __sighandler_t sighandler_t;
237 #endif
238
239 /* 4.4 BSD uses the name `sig_t' for this.  */
240 #ifdef __USE_BSD
241 typedef __sighandler_t sig_t;
242 #endif
243
244 #ifdef __USE_POSIX
245
246 /* Clear all signals from SET.  */
247 extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
248
249 /* Set all signals in SET.  */
250 extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
251
252 /* Add SIGNO to SET.  */
253 extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
254 libc_hidden_proto(sigaddset)
255
256 /* Remove SIGNO from SET.  */
257 extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
258 libc_hidden_proto(sigdelset)
259
260 /* Return 1 if SIGNO is in SET, 0 if not.  */
261 extern int sigismember (const sigset_t *__set, int __signo)
262      __THROW __nonnull ((1));
263
264 # ifdef __USE_GNU
265 /* Return non-empty value is SET is not empty.  */
266 extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1));
267
268 /* Build new signal set by combining the two inputs set using logical AND.  */
269 extern int sigandset (sigset_t *__set, const sigset_t *__left,
270                       const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
271
272 /* Build new signal set by combining the two inputs set using logical OR.  */
273 extern int sigorset (sigset_t *__set, const sigset_t *__left,
274                      const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
275 # endif /* GNU */
276
277 /* Get the system-specific definitions of `struct sigaction'
278    and the `SA_*' and `SIG_*'. constants.  */
279 # include <bits/sigaction.h>
280
281 /* Get and/or change the set of blocked signals.  */
282 extern int sigprocmask (int __how, const sigset_t *__restrict __set,
283                         sigset_t *__restrict __oset) __THROW;
284 libc_hidden_proto(sigprocmask)
285
286 /* Change the set of blocked signals to SET,
287    wait until a signal arrives, and restore the set of blocked signals.
288
289    This function is a cancellation point and therefore not marked with
290    __THROW.  */
291 extern int sigsuspend (const sigset_t *__set) __nonnull ((1));
292 #ifdef _LIBC
293 extern __typeof(sigsuspend) __sigsuspend_nocancel attribute_hidden;
294 libc_hidden_proto(sigsuspend)
295 #endif
296
297 /* Get and/or set the action for signal SIG.  */
298 extern int sigaction (int __sig, const struct sigaction *__restrict __act,
299                       struct sigaction *__restrict __oact) __THROW;
300 #ifdef _LIBC
301 # if 0 /* this is in headers */
302 /* In uclibc, userspace struct sigaction is identical to
303  * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel).
304  * See sigaction.h
305  */
306 struct old_kernel_sigaction;
307 extern int __syscall_sigaction(int, const struct old_kernel_sigaction *,
308         struct old_kernel_sigaction *) attribute_hidden;
309 # else /* this is how the function is built */
310 extern __typeof(sigaction) __syscall_sigaction attribute_hidden;
311 # endif
312 # define __need_size_t
313 # include <stddef.h>
314 /* candidate for attribute_hidden, if NPTL would behave */
315 extern int __syscall_rt_sigaction(int, const struct sigaction *,
316         struct sigaction *, size_t)
317 # ifndef __UCLIBC_HAS_THREADS_NATIVE__
318                 attribute_hidden
319 # endif
320         ;
321 extern __typeof(sigaction) __libc_sigaction;
322 libc_hidden_proto(sigaction)
323
324 # ifdef __mips__
325 #  define _KERNEL_NSIG_WORDS (_NSIG / _MIPS_SZLONG)
326 typedef struct {
327         unsigned long sig[_KERNEL_NSIG_WORDS];
328 } kernel_sigset_t;
329 #  define __SYSCALL_SIGSET_T_SIZE (sizeof(kernel_sigset_t))
330 # else
331 #  define __SYSCALL_SIGSET_T_SIZE (_NSIG / 8)
332 # endif
333 #endif
334
335 /* Put in SET all signals that are blocked and waiting to be delivered.  */
336 extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
337
338
339 /* Select any of pending signals from SET or wait for any to arrive.
340
341    This function is a cancellation point and therefore not marked with
342    __THROW.  */
343 extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
344      __nonnull ((1, 2));
345
346 # if defined __USE_POSIX199309 && defined __UCLIBC_HAS_REALTIME__
347 /* Select any of pending signals from SET and place information in INFO.
348
349    This function is a cancellation point and therefore not marked with
350    __THROW.  */
351 extern int sigwaitinfo (const sigset_t *__restrict __set,
352                         siginfo_t *__restrict __info) __nonnull ((1));
353 #ifdef _LIBC
354 extern __typeof(sigwaitinfo) __sigwaitinfo attribute_hidden;
355 #endif
356
357 /* Select any of pending signals from SET and place information in INFO.
358    Wait the time specified by TIMEOUT if no signal is pending.
359
360    This function is a cancellation point and therefore not marked with
361    __THROW.  */
362 extern int sigtimedwait (const sigset_t *__restrict __set,
363                          siginfo_t *__restrict __info,
364                          const struct timespec *__restrict __timeout)
365      __nonnull ((1));
366 #ifdef _LIBC
367 extern __typeof(sigtimedwait) __sigtimedwait_nocancel attribute_hidden;
368 libc_hidden_proto(sigtimedwait)
369 #endif
370
371 /* Send signal SIG to the process PID.  Associate data in VAL with the
372    signal.  */
373 extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
374      __THROW;
375 # endif /* Use POSIX 199306.  */
376
377 #endif /* Use POSIX.  */
378
379 #ifdef __USE_BSD
380
381 # ifdef __UCLIBC_HAS_SYS_SIGLIST__
382 /* Names of the signals.  This variable exists only for compatibility.
383    Use `strsignal' instead (see <string.h>).  */
384 #  define _sys_siglist sys_siglist
385 extern const char *const sys_siglist[_NSIG];
386 # endif
387
388 #ifndef __UCLIBC_STRICT_HEADERS__
389 /* Structure passed to `sigvec'.  */
390 struct sigvec
391   {
392     __sighandler_t sv_handler;  /* Signal handler.  */
393     int sv_mask;                /* Mask of signals to be blocked.  */
394
395     int sv_flags;               /* Flags (see below).  */
396 # define sv_onstack     sv_flags /* 4.2 BSD compatibility.  */
397   };
398
399 /* Bits in `sv_flags'.  */
400 # define SV_ONSTACK     (1 << 0)/* Take the signal on the signal stack.  */
401 # define SV_INTERRUPT   (1 << 1)/* Do not restart system calls.  */
402 # define SV_RESETHAND   (1 << 2)/* Reset handler to SIG_DFL on receipt.  */
403 #endif
404
405
406 #if 0
407 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
408    of VEC.  The signals in `sv_mask' will be blocked while the handler runs.
409    If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
410    reset to SIG_DFL before `sv_handler' is entered.  If OVEC is non-NULL,
411    it is filled in with the old information for SIG.  */
412 extern int sigvec (int __sig, const struct sigvec *__vec,
413                    struct sigvec *__ovec) __THROW;
414 #endif
415
416
417 /* Get machine-dependent `struct sigcontext' and signal subcodes.  */
418 # include <bits/sigcontext.h>
419
420 #if 0
421 /* Restore the state saved in SCP.  */
422 extern int sigreturn (struct sigcontext *__scp) __THROW;
423 #endif
424
425 #endif /*  use BSD.  */
426
427
428 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
429 # define __need_size_t
430 # include <stddef.h>
431
432 # ifdef __UCLIBC_SUSV4_LEGACY__
433 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
434    (causing them to fail with EINTR); if INTERRUPT is zero, make system
435    calls be restarted after signal SIG.  */
436 extern int siginterrupt (int __sig, int __interrupt) __THROW;
437 # endif
438
439 # include <bits/sigstack.h>
440 # ifdef __USE_XOPEN
441 /* This will define `ucontext_t' and `mcontext_t'.  */
442 /* SuSv4 obsoleted include/ucontext.h */
443 #  include <sys/ucontext.h>
444 # endif
445
446 # if 0
447 /* Run signals handlers on the stack specified by SS (if not NULL).
448    If OSS is not NULL, it is filled in with the old signal stack status.
449    This interface is obsolete and on many platform not implemented.  */
450 extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
451      __THROW __attribute_deprecated__;
452 # endif
453
454 /* Alternate signal handler stack interface.
455    This interface should always be preferred over `sigstack'.  */
456 extern int sigaltstack (const struct sigaltstack *__restrict __ss,
457                         struct sigaltstack *__restrict __oss) __THROW;
458
459 #endif /* use BSD or X/Open Unix.  */
460
461 #if defined __USE_XOPEN_EXTENDED && defined __UCLIBC_HAS_OBSOLETE_BSD_SIGNAL__
462 /* Simplified interface for signal management.  */
463
464 /* Add SIG to the calling process' signal mask.  */
465 extern int sighold (int __sig) __THROW;
466
467 /* Remove SIG from the calling process' signal mask.  */
468 extern int sigrelse (int __sig) __THROW;
469
470 /* Set the disposition of SIG to SIG_IGN.  */
471 extern int sigignore (int __sig) __THROW;
472
473 /* Set the disposition of SIG.  */
474 extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
475 #endif
476
477 #if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98)
478 /* Some of the functions for handling signals in threaded programs must
479    be defined here.  */
480 # include <bits/pthreadtypes.h>
481 # include <bits/sigthread.h>
482 #endif
483
484 /* The following functions are used internally in the C library and in
485    other code which need deep insights.  */
486
487 /* Return number of available real-time signal with highest priority.  */
488 extern int __libc_current_sigrtmin (void) __THROW;
489 /* Return number of available real-time signal with lowest priority.  */
490 extern int __libc_current_sigrtmax (void) __THROW;
491
492 #ifdef _LIBC
493 extern sigset_t _sigintr attribute_hidden;
494 /* simplified version without parameter checking */
495 # include <string.h>
496 # undef __sigemptyset
497 # define __sigemptyset(ss) (memset(ss, '\0', sizeof(sigset_t)), 0)
498 #endif
499 #endif /* signal.h  */
500
501 __END_DECLS
502
503 #endif /* not signal.h */