blob: cbbb42a74fa10877c0060255dc99a957eb7edd4f [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 Felker0b44a032011-02-12 00:22:29 -050011#define __NEED_size_t
12#define __NEED_pid_t
13#define __NEED_uid_t
14#define __NEED_struct_timespec
15#define __NEED_pthread_t
Rich Felker80c4dcd2011-03-29 13:01:25 -040016#define __NEED_pthread_attr_t
Rich Felker0b44a032011-02-12 00:22:29 -050017#define __NEED_time_t
18#define __NEED_clock_t
19#define __NEED_sigset_t
20#define __NEED_siginfo_t
21
22#include <bits/alltypes.h>
23
Rich Felkerf780ac52011-09-19 20:02:12 -040024#define SIG_BLOCK 0
25#define SIG_UNBLOCK 1
26#define SIG_SETMASK 2
27
28#define SIG_ERR ((void (*)(int))-1)
29#define SIG_DFL ((void (*)(int)) 0)
30#define SIG_IGN ((void (*)(int)) 1)
31#define SIG_HOLD ((void (*)(int)) 2)
32
33#define SI_ASYNCNL (-60)
34#define SI_TKILL (-6)
35#define SI_SIGIO (-5)
36#define SI_ASYNCIO (-4)
37#define SI_MESGQ (-3)
38#define SI_TIMER (-2)
39#define SI_QUEUE (-1)
40#define SI_USER 0
41#define SI_KERNEL 128
42
43#define FPE_INTDIV 1
44#define FPE_INTOVF 2
45#define FPE_FLTDIV 3
46#define FPE_FLTOVF 4
47#define FPE_FLTUNT 5
48#define FPE_FLTRES 6
49#define FPE_FLTINV 7
50#define FPE_FLTSUB 8
51
52#define ILL_ILLOPC 1
53#define ILL_ILLOPN 2
54#define ILL_ILLADR 3
55#define ILL_ILLTRP 4
56#define ILL_PRVOPC 5
57#define ILL_PRVREG 6
58#define ILL_COPROC 7
59#define ILL_BADSTK 8
60
61#define SEGV_MAPERR 1
62#define SEGV_ACCERR 2
63
64#define BUS_ADRALN 1
65#define BUS_ADRERR 2
66#define BUS_OBJERR 3
67
68#define CLD_EXITED 1
69#define CLD_KILLED 2
70#define CLD_DUMPED 3
71#define CLD_TRAPPED 4
72#define CLD_STOPPED 5
73#define CLD_CONTINUED 6
74
Rich Felker80c4dcd2011-03-29 13:01:25 -040075struct sigaction {
Rich Felker0b44a032011-02-12 00:22:29 -050076 union {
77 void (*sa_handler)(int);
78 void (*sa_sigaction)(int, siginfo_t *, void *);
79 } __sa_handler;
80 sigset_t sa_mask;
81 int sa_flags;
82 void (*__sa_restorer)(void);
83};
84#define sa_handler __sa_handler.sa_handler
85#define sa_sigaction __sa_handler.sa_sigaction
86
Rich Felker80c4dcd2011-03-29 13:01:25 -040087typedef struct {
Rich Felker0b44a032011-02-12 00:22:29 -050088 void *ss_sp;
89 int ss_flags;
90 size_t ss_size;
91} stack_t;
92
Rich Felker80c4dcd2011-03-29 13:01:25 -040093union sigval {
Rich Felker0b44a032011-02-12 00:22:29 -050094 int sival_int;
95 void *sival_ptr;
96};
97
Rich Felkerf780ac52011-09-19 20:02:12 -040098#ifdef _GNU_SOURCE
99struct siginfo
100#else
101struct __siginfo
102#endif
103{
104 int si_signo, si_errno, si_code;
105 union {
106 char __pad[128 - 3*sizeof(int)];
107 struct {
108 pid_t si_pid;
109 uid_t si_uid;
110 union sigval si_sigval;
111 } __rt;
112 struct {
113 unsigned int si_timer1, si_timer2;
114 } __timer;
115 struct {
116 pid_t si_pid;
117 uid_t si_uid;
118 int si_status;
119 clock_t si_utime, si_stime;
120 } __sigchld;
121 struct {
122 void *si_addr;
123 } __sigfault;
124 struct {
125 long si_band;
126 int si_fd;
127 } __sigpoll;
128 } __si_fields;
129};
130#define si_pid __si_fields.__sigchld.si_pid
131#define si_uid __si_fields.__sigchld.si_uid
132#define si_status __si_fields.__sigchld.si_status
133#define si_utime __si_fields.__sigchld.si_utime
134#define si_stime __si_fields.__sigchld.si_stime
135#define si_value __si_fields.__rt.si_sigval
136#define si_addr __si_fields.__sigfault.si_addr
137#define si_band __si_fields.__sigpoll.si_band
138#define si_fd __si_fields.__sigpoll.si_fd
139#define si_timer1 __si_fields.__timer.si_timer1
140#define si_timer2 __si_fields.__timer.si_timer2
Rich Felker8c07f6e2011-09-19 22:27:02 -0400141#define si_ptr __si_fields.__rt.si_sigval.sival_ptr
142#define si_int __si_fields.__rt.si_sigval.sival_int
Rich Felkerf780ac52011-09-19 20:02:12 -0400143
Rich Felker80c4dcd2011-03-29 13:01:25 -0400144struct sigevent {
145 union sigval sigev_value;
146 int sigev_signo;
147 int sigev_notify;
148 void (*sigev_notify_function)(union sigval);
149 pthread_attr_t *sigev_notify_attributes;
Rich Felker7f547152011-06-16 17:11:35 -0400150 char __pad[56-3*sizeof(long)];
Rich Felker80c4dcd2011-03-29 13:01:25 -0400151};
152
153#define SIGEV_SIGNAL 0
154#define SIGEV_NONE 1
155#define SIGEV_THREAD 2
156
Rich Felker0b44a032011-02-12 00:22:29 -0500157int __libc_current_sigrtmin(void);
158int __libc_current_sigrtmax(void);
159
160#define SIGRTMIN (__libc_current_sigrtmin())
161#define SIGRTMAX (__libc_current_sigrtmax())
162
Rich Felker0b44a032011-02-12 00:22:29 -0500163int kill(pid_t, int);
Rich Felker0b44a032011-02-12 00:22:29 -0500164
165int sigemptyset(sigset_t *);
166int sigfillset(sigset_t *);
167int sigaddset(sigset_t *, int);
168int sigdelset(sigset_t *, int);
169int sigismember(const sigset_t *, int);
170
171int sigprocmask(int, const sigset_t *, sigset_t *);
172int sigsuspend(const sigset_t *);
173int sigaction(int, const struct sigaction *, struct sigaction *);
174int sigpending(sigset_t *);
175int sigwait(const sigset_t *, int *);
176int sigwaitinfo(const sigset_t *, siginfo_t *);
177int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
178int sigqueue(pid_t, int, const union sigval);
179
Rich Felker0b44a032011-02-12 00:22:29 -0500180int pthread_sigmask(int, const sigset_t *, sigset_t *);
181int pthread_kill(pthread_t, int);
182
Rich Felkeradb70932011-09-02 14:25:43 -0400183void psiginfo(const siginfo_t *, const char *);
184void psignal(int, const char *);
185
Rich Felker1322cb82011-02-14 20:33:54 -0500186#endif
187
188#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
189int killpg(pid_t, int);
190int sigaltstack(const stack_t *, stack_t *);
191int sighold(int);
192int sigignore(int);
193int siginterrupt(int, int);
194int sigpause(int);
195int sigrelse(int);
196void (*sigset(int, void (*)(int)))(int);
Rich Felkerf780ac52011-09-19 20:02:12 -0400197#define TRAP_BRKPT 1
198#define TRAP_TRACE 2
199#define POLL_IN 1
200#define POLL_OUT 2
201#define POLL_MSG 3
202#define POLL_ERR 4
203#define POLL_PRI 5
204#define POLL_HUP 6
205#define SS_ONSTACK 1
206#define SS_DISABLE 2
207#define MINSIGSTKSZ 2048
208#define SIGSTKSZ 8192
Rich Felker1322cb82011-02-14 20:33:54 -0500209#endif
210
Rich Felker0b44a032011-02-12 00:22:29 -0500211#ifdef _GNU_SOURCE
Rich Felker0f5b4352011-04-13 08:45:28 -0400212typedef void (*sighandler_t)(int);
Rich Felker1322cb82011-02-14 20:33:54 -0500213void (*bsd_signal(int, void (*)(int)))(int);
Rich Felkerfb80e042011-09-12 00:00:30 -0400214int sigisemptyset(const sigset_t *);
Rich Felker20291142011-05-05 17:44:06 -0400215#define SA_NOMASK SA_NODEFER
Rich Felkerf780ac52011-09-19 20:02:12 -0400216#define SA_ONESHOT SA_RESETHAND
Rich Felker0b44a032011-02-12 00:22:29 -0500217#endif
218
Rich Felker3eb9fea2011-02-15 15:10:00 -0500219#include <bits/signal.h>
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