blob: 7f30be3368063c1b2b3f92f354275a7b7c3fd197 [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#ifndef _SIGNAL_H
2#define _SIGNAL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
Rich Felker1322cb82011-02-14 20:33:54 -05008#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
9 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
10
Rich Felker03a83622011-09-20 10:58:18 -040011#ifdef _GNU_SOURCE
12#define __siginfo siginfo
13#endif
14
Rich Felker0b44a032011-02-12 00:22:29 -050015#define __NEED_size_t
16#define __NEED_pid_t
17#define __NEED_uid_t
18#define __NEED_struct_timespec
19#define __NEED_pthread_t
Rich Felker80c4dcd2011-03-29 13:01:25 -040020#define __NEED_pthread_attr_t
Rich Felker0b44a032011-02-12 00:22:29 -050021#define __NEED_time_t
22#define __NEED_clock_t
23#define __NEED_sigset_t
24#define __NEED_siginfo_t
25
26#include <bits/alltypes.h>
27
Rich Felker81a55772011-09-21 22:25:31 -040028#define SIG_HOLD ((void (*)(int)) 2)
29
Rich Felkerf780ac52011-09-19 20:02:12 -040030#define SIG_BLOCK 0
31#define SIG_UNBLOCK 1
32#define SIG_SETMASK 2
33
Rich Felkerf780ac52011-09-19 20:02:12 -040034#define SI_ASYNCNL (-60)
35#define SI_TKILL (-6)
36#define SI_SIGIO (-5)
37#define SI_ASYNCIO (-4)
38#define SI_MESGQ (-3)
39#define SI_TIMER (-2)
40#define SI_QUEUE (-1)
41#define SI_USER 0
42#define SI_KERNEL 128
43
44#define FPE_INTDIV 1
45#define FPE_INTOVF 2
46#define FPE_FLTDIV 3
47#define FPE_FLTOVF 4
48#define FPE_FLTUNT 5
49#define FPE_FLTRES 6
50#define FPE_FLTINV 7
51#define FPE_FLTSUB 8
52
53#define ILL_ILLOPC 1
54#define ILL_ILLOPN 2
55#define ILL_ILLADR 3
56#define ILL_ILLTRP 4
57#define ILL_PRVOPC 5
58#define ILL_PRVREG 6
59#define ILL_COPROC 7
60#define ILL_BADSTK 8
61
62#define SEGV_MAPERR 1
63#define SEGV_ACCERR 2
64
65#define BUS_ADRALN 1
66#define BUS_ADRERR 2
67#define BUS_OBJERR 3
68
69#define CLD_EXITED 1
70#define CLD_KILLED 2
71#define CLD_DUMPED 3
72#define CLD_TRAPPED 4
73#define CLD_STOPPED 5
74#define CLD_CONTINUED 6
75
Rich Felker80c4dcd2011-03-29 13:01:25 -040076struct sigaction {
Rich Felker0b44a032011-02-12 00:22:29 -050077 union {
78 void (*sa_handler)(int);
79 void (*sa_sigaction)(int, siginfo_t *, void *);
80 } __sa_handler;
81 sigset_t sa_mask;
82 int sa_flags;
83 void (*__sa_restorer)(void);
84};
85#define sa_handler __sa_handler.sa_handler
86#define sa_sigaction __sa_handler.sa_sigaction
87
Rich Felker80c4dcd2011-03-29 13:01:25 -040088typedef struct {
Rich Felker0b44a032011-02-12 00:22:29 -050089 void *ss_sp;
90 int ss_flags;
91 size_t ss_size;
92} stack_t;
93
Rich Felker80c4dcd2011-03-29 13:01:25 -040094union sigval {
Rich Felker0b44a032011-02-12 00:22:29 -050095 int sival_int;
96 void *sival_ptr;
97};
98
Rich Felker03a83622011-09-20 10:58:18 -040099struct __siginfo {
Rich Felkerf780ac52011-09-19 20:02:12 -0400100 int si_signo, si_errno, si_code;
101 union {
102 char __pad[128 - 3*sizeof(int)];
103 struct {
104 pid_t si_pid;
105 uid_t si_uid;
106 union sigval si_sigval;
107 } __rt;
108 struct {
109 unsigned int si_timer1, si_timer2;
110 } __timer;
111 struct {
112 pid_t si_pid;
113 uid_t si_uid;
114 int si_status;
115 clock_t si_utime, si_stime;
116 } __sigchld;
117 struct {
118 void *si_addr;
119 } __sigfault;
120 struct {
121 long si_band;
122 int si_fd;
123 } __sigpoll;
124 } __si_fields;
125};
126#define si_pid __si_fields.__sigchld.si_pid
127#define si_uid __si_fields.__sigchld.si_uid
128#define si_status __si_fields.__sigchld.si_status
129#define si_utime __si_fields.__sigchld.si_utime
130#define si_stime __si_fields.__sigchld.si_stime
131#define si_value __si_fields.__rt.si_sigval
132#define si_addr __si_fields.__sigfault.si_addr
133#define si_band __si_fields.__sigpoll.si_band
134#define si_fd __si_fields.__sigpoll.si_fd
135#define si_timer1 __si_fields.__timer.si_timer1
136#define si_timer2 __si_fields.__timer.si_timer2
Rich Felker8c07f6e2011-09-19 22:27:02 -0400137#define si_ptr __si_fields.__rt.si_sigval.sival_ptr
138#define si_int __si_fields.__rt.si_sigval.sival_int
Rich Felkerf780ac52011-09-19 20:02:12 -0400139
Rich Felker80c4dcd2011-03-29 13:01:25 -0400140struct sigevent {
141 union sigval sigev_value;
142 int sigev_signo;
143 int sigev_notify;
144 void (*sigev_notify_function)(union sigval);
145 pthread_attr_t *sigev_notify_attributes;
Rich Felker7f547152011-06-16 17:11:35 -0400146 char __pad[56-3*sizeof(long)];
Rich Felker80c4dcd2011-03-29 13:01:25 -0400147};
148
149#define SIGEV_SIGNAL 0
150#define SIGEV_NONE 1
151#define SIGEV_THREAD 2
152
Rich Felker0b44a032011-02-12 00:22:29 -0500153int __libc_current_sigrtmin(void);
154int __libc_current_sigrtmax(void);
155
156#define SIGRTMIN (__libc_current_sigrtmin())
157#define SIGRTMAX (__libc_current_sigrtmax())
158
Rich Felker0b44a032011-02-12 00:22:29 -0500159int kill(pid_t, int);
Rich Felker0b44a032011-02-12 00:22:29 -0500160
161int sigemptyset(sigset_t *);
162int sigfillset(sigset_t *);
163int sigaddset(sigset_t *, int);
164int sigdelset(sigset_t *, int);
165int sigismember(const sigset_t *, int);
166
167int sigprocmask(int, const sigset_t *, sigset_t *);
168int sigsuspend(const sigset_t *);
169int sigaction(int, const struct sigaction *, struct sigaction *);
170int sigpending(sigset_t *);
171int sigwait(const sigset_t *, int *);
172int sigwaitinfo(const sigset_t *, siginfo_t *);
173int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
174int sigqueue(pid_t, int, const union sigval);
175
Rich Felker0b44a032011-02-12 00:22:29 -0500176int pthread_sigmask(int, const sigset_t *, sigset_t *);
177int pthread_kill(pthread_t, int);
178
Rich Felkeradb70932011-09-02 14:25:43 -0400179void psiginfo(const siginfo_t *, const char *);
180void psignal(int, const char *);
181
Rich Felker1322cb82011-02-14 20:33:54 -0500182#endif
183
184#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
185int killpg(pid_t, int);
186int sigaltstack(const stack_t *, stack_t *);
187int sighold(int);
188int sigignore(int);
189int siginterrupt(int, int);
190int sigpause(int);
191int sigrelse(int);
192void (*sigset(int, void (*)(int)))(int);
Rich Felkerf780ac52011-09-19 20:02:12 -0400193#define TRAP_BRKPT 1
194#define TRAP_TRACE 2
195#define POLL_IN 1
196#define POLL_OUT 2
197#define POLL_MSG 3
198#define POLL_ERR 4
199#define POLL_PRI 5
200#define POLL_HUP 6
201#define SS_ONSTACK 1
202#define SS_DISABLE 2
203#define MINSIGSTKSZ 2048
204#define SIGSTKSZ 8192
Rich Felker1322cb82011-02-14 20:33:54 -0500205#endif
206
Rich Felker0b44a032011-02-12 00:22:29 -0500207#ifdef _GNU_SOURCE
Rich Felker0f5b4352011-04-13 08:45:28 -0400208typedef void (*sighandler_t)(int);
Rich Felker1322cb82011-02-14 20:33:54 -0500209void (*bsd_signal(int, void (*)(int)))(int);
Rich Felkerfb80e042011-09-12 00:00:30 -0400210int sigisemptyset(const sigset_t *);
Rich Felker20291142011-05-05 17:44:06 -0400211#define SA_NOMASK SA_NODEFER
Rich Felkerf780ac52011-09-19 20:02:12 -0400212#define SA_ONESHOT SA_RESETHAND
Rich Felker0b44a032011-02-12 00:22:29 -0500213#endif
214
Rich Felker3eb9fea2011-02-15 15:10:00 -0500215#include <bits/signal.h>
216
Rich Felker81a55772011-09-21 22:25:31 -0400217#define SIG_ERR ((void (*)(int))-1)
218#define SIG_DFL ((void (*)(int)) 0)
219#define SIG_IGN ((void (*)(int)) 1)
220
Rich Felker1322cb82011-02-14 20:33:54 -0500221typedef int sig_atomic_t;
222
223void (*signal(int, void (*)(int)))(int);
224int raise(int);
225
Rich Felker0b44a032011-02-12 00:22:29 -0500226#ifdef __cplusplus
227}
228#endif
229
230#endif