Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | #ifndef _SIGNAL_H |
| 2 | #define _SIGNAL_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Rich Felker | c1a9658 | 2012-09-07 23:13:55 -0400 | [diff] [blame] | 8 | #include <features.h> |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 9 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 10 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 11 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ |
| 12 | || defined(_BSD_SOURCE) |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 13 | |
Rich Felker | 03a8362 | 2011-09-20 10:58:18 -0400 | [diff] [blame] | 14 | #ifdef _GNU_SOURCE |
Rich Felker | a8da6c2 | 2012-11-25 23:04:23 -0500 | [diff] [blame] | 15 | #define __ucontext ucontext |
Rich Felker | 03a8362 | 2011-09-20 10:58:18 -0400 | [diff] [blame] | 16 | #endif |
| 17 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 18 | #define __NEED_size_t |
| 19 | #define __NEED_pid_t |
| 20 | #define __NEED_uid_t |
| 21 | #define __NEED_struct_timespec |
| 22 | #define __NEED_pthread_t |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 23 | #define __NEED_pthread_attr_t |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 24 | #define __NEED_time_t |
| 25 | #define __NEED_clock_t |
| 26 | #define __NEED_sigset_t |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 27 | |
| 28 | #include <bits/alltypes.h> |
| 29 | |
Rich Felker | 81a5577 | 2011-09-21 22:25:31 -0400 | [diff] [blame] | 30 | #define SIG_HOLD ((void (*)(int)) 2) |
| 31 | |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 32 | #define SIG_BLOCK 0 |
| 33 | #define SIG_UNBLOCK 1 |
| 34 | #define SIG_SETMASK 2 |
| 35 | |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 36 | #define SI_ASYNCNL (-60) |
| 37 | #define SI_TKILL (-6) |
| 38 | #define SI_SIGIO (-5) |
| 39 | #define SI_ASYNCIO (-4) |
| 40 | #define SI_MESGQ (-3) |
| 41 | #define SI_TIMER (-2) |
| 42 | #define SI_QUEUE (-1) |
| 43 | #define SI_USER 0 |
| 44 | #define SI_KERNEL 128 |
| 45 | |
| 46 | #define FPE_INTDIV 1 |
| 47 | #define FPE_INTOVF 2 |
| 48 | #define FPE_FLTDIV 3 |
| 49 | #define FPE_FLTOVF 4 |
Rich Felker | 8eb9a3a | 2012-01-25 15:30:42 -0500 | [diff] [blame] | 50 | #define FPE_FLTUND 5 |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 51 | #define FPE_FLTRES 6 |
| 52 | #define FPE_FLTINV 7 |
| 53 | #define FPE_FLTSUB 8 |
| 54 | |
| 55 | #define ILL_ILLOPC 1 |
| 56 | #define ILL_ILLOPN 2 |
| 57 | #define ILL_ILLADR 3 |
| 58 | #define ILL_ILLTRP 4 |
| 59 | #define ILL_PRVOPC 5 |
| 60 | #define ILL_PRVREG 6 |
| 61 | #define ILL_COPROC 7 |
| 62 | #define ILL_BADSTK 8 |
| 63 | |
| 64 | #define SEGV_MAPERR 1 |
| 65 | #define SEGV_ACCERR 2 |
| 66 | |
| 67 | #define BUS_ADRALN 1 |
| 68 | #define BUS_ADRERR 2 |
| 69 | #define BUS_OBJERR 3 |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 70 | #define BUS_MCEERR_AR 4 |
| 71 | #define BUS_MCEERR_AO 5 |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 72 | |
| 73 | #define CLD_EXITED 1 |
| 74 | #define CLD_KILLED 2 |
| 75 | #define CLD_DUMPED 3 |
| 76 | #define CLD_TRAPPED 4 |
| 77 | #define CLD_STOPPED 5 |
| 78 | #define CLD_CONTINUED 6 |
| 79 | |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 80 | typedef struct sigaltstack { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 81 | void *ss_sp; |
| 82 | int ss_flags; |
| 83 | size_t ss_size; |
| 84 | } stack_t; |
| 85 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 86 | union sigval { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 87 | int sival_int; |
| 88 | void *sival_ptr; |
| 89 | }; |
| 90 | |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 91 | typedef struct { |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 92 | int si_signo, si_errno, si_code; |
| 93 | union { |
Rich Felker | 8c74178 | 2013-03-04 17:05:45 -0500 | [diff] [blame] | 94 | char __pad[128 - 2*sizeof(int) - sizeof(long)]; |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 95 | struct { |
| 96 | pid_t si_pid; |
| 97 | uid_t si_uid; |
| 98 | union sigval si_sigval; |
| 99 | } __rt; |
| 100 | struct { |
| 101 | unsigned int si_timer1, si_timer2; |
| 102 | } __timer; |
| 103 | struct { |
| 104 | pid_t si_pid; |
| 105 | uid_t si_uid; |
| 106 | int si_status; |
| 107 | clock_t si_utime, si_stime; |
| 108 | } __sigchld; |
| 109 | struct { |
| 110 | void *si_addr; |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 111 | short int si_addr_lsb; |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 112 | } __sigfault; |
| 113 | struct { |
| 114 | long si_band; |
| 115 | int si_fd; |
| 116 | } __sigpoll; |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 117 | struct { |
| 118 | unsigned int si_call_addr; |
| 119 | int si_syscall; |
| 120 | unsigned int si_arch; |
| 121 | } __sigsys; |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 122 | } __si_fields; |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 123 | } siginfo_t; |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 124 | #define si_pid __si_fields.__sigchld.si_pid |
| 125 | #define si_uid __si_fields.__sigchld.si_uid |
| 126 | #define si_status __si_fields.__sigchld.si_status |
| 127 | #define si_utime __si_fields.__sigchld.si_utime |
| 128 | #define si_stime __si_fields.__sigchld.si_stime |
| 129 | #define si_value __si_fields.__rt.si_sigval |
| 130 | #define si_addr __si_fields.__sigfault.si_addr |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 131 | #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 132 | #define si_band __si_fields.__sigpoll.si_band |
| 133 | #define si_fd __si_fields.__sigpoll.si_fd |
| 134 | #define si_timer1 __si_fields.__timer.si_timer1 |
| 135 | #define si_timer2 __si_fields.__timer.si_timer2 |
Rich Felker | 8c07f6e | 2011-09-19 22:27:02 -0400 | [diff] [blame] | 136 | #define si_ptr __si_fields.__rt.si_sigval.sival_ptr |
| 137 | #define si_int __si_fields.__rt.si_sigval.sival_int |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 138 | #define si_call_addr __si_fields.__sigsys.si_call_addr |
| 139 | #define si_syscall __si_fields.__sigsys.si_syscall |
| 140 | #define si_arch __si_fields.__sigsys.si_arch |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 141 | |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 142 | struct sigaction { |
| 143 | union { |
| 144 | void (*sa_handler)(int); |
| 145 | void (*sa_sigaction)(int, siginfo_t *, void *); |
| 146 | } __sa_handler; |
| 147 | sigset_t sa_mask; |
| 148 | int sa_flags; |
Szabolcs Nagy | b54f169 | 2013-07-24 23:56:13 +0000 | [diff] [blame^] | 149 | void (*sa_restorer)(void); |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 150 | }; |
| 151 | #define sa_handler __sa_handler.sa_handler |
| 152 | #define sa_sigaction __sa_handler.sa_sigaction |
| 153 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 154 | struct sigevent { |
| 155 | union sigval sigev_value; |
| 156 | int sigev_signo; |
| 157 | int sigev_notify; |
| 158 | void (*sigev_notify_function)(union sigval); |
| 159 | pthread_attr_t *sigev_notify_attributes; |
Rich Felker | 7f54715 | 2011-06-16 17:11:35 -0400 | [diff] [blame] | 160 | char __pad[56-3*sizeof(long)]; |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | #define SIGEV_SIGNAL 0 |
| 164 | #define SIGEV_NONE 1 |
| 165 | #define SIGEV_THREAD 2 |
| 166 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 167 | int __libc_current_sigrtmin(void); |
| 168 | int __libc_current_sigrtmax(void); |
| 169 | |
| 170 | #define SIGRTMIN (__libc_current_sigrtmin()) |
| 171 | #define SIGRTMAX (__libc_current_sigrtmax()) |
| 172 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 173 | int kill(pid_t, int); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 174 | |
| 175 | int sigemptyset(sigset_t *); |
| 176 | int sigfillset(sigset_t *); |
| 177 | int sigaddset(sigset_t *, int); |
| 178 | int sigdelset(sigset_t *, int); |
| 179 | int sigismember(const sigset_t *, int); |
| 180 | |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 181 | int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 182 | int sigsuspend(const sigset_t *); |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 183 | int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 184 | int sigpending(sigset_t *); |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 185 | int sigwait(const sigset_t *__restrict, int *__restrict); |
| 186 | int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict); |
| 187 | int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 188 | int sigqueue(pid_t, int, const union sigval); |
| 189 | |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 190 | int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 191 | int pthread_kill(pthread_t, int); |
| 192 | |
Rich Felker | adb7093 | 2011-09-02 14:25:43 -0400 | [diff] [blame] | 193 | void psiginfo(const siginfo_t *, const char *); |
| 194 | void psignal(int, const char *); |
| 195 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 196 | #endif |
| 197 | |
| 198 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 199 | int killpg(pid_t, int); |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 200 | int sigaltstack(const stack_t *__restrict, stack_t *__restrict); |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 201 | int sighold(int); |
| 202 | int sigignore(int); |
| 203 | int siginterrupt(int, int); |
| 204 | int sigpause(int); |
| 205 | int sigrelse(int); |
| 206 | void (*sigset(int, void (*)(int)))(int); |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 207 | #define TRAP_BRKPT 1 |
| 208 | #define TRAP_TRACE 2 |
| 209 | #define POLL_IN 1 |
| 210 | #define POLL_OUT 2 |
| 211 | #define POLL_MSG 3 |
| 212 | #define POLL_ERR 4 |
| 213 | #define POLL_PRI 5 |
| 214 | #define POLL_HUP 6 |
| 215 | #define SS_ONSTACK 1 |
| 216 | #define SS_DISABLE 2 |
| 217 | #define MINSIGSTKSZ 2048 |
| 218 | #define SIGSTKSZ 8192 |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 219 | #endif |
| 220 | |
Rich Felker | 7dcb640 | 2012-11-30 21:00:18 -0500 | [diff] [blame] | 221 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 222 | #define NSIG _NSIG |
| 223 | #endif |
| 224 | |
Rich Felker | 769fd4c | 2012-12-03 16:57:01 -0500 | [diff] [blame] | 225 | #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 226 | typedef void (*sig_t)(int); |
| 227 | #endif |
| 228 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 229 | #ifdef _GNU_SOURCE |
Rich Felker | 0f5b435 | 2011-04-13 08:45:28 -0400 | [diff] [blame] | 230 | typedef void (*sighandler_t)(int); |
Rich Felker | 9f370fa | 2012-05-22 21:54:19 -0400 | [diff] [blame] | 231 | void (*bsd_signal(int, void (*)(int)))(int); |
Rich Felker | fb80e04 | 2011-09-12 00:00:30 -0400 | [diff] [blame] | 232 | int sigisemptyset(const sigset_t *); |
rofl0r | a1990e1 | 2012-12-06 20:51:32 +0100 | [diff] [blame] | 233 | int sigorset (sigset_t *, sigset_t *, sigset_t *); |
| 234 | int sigandset(sigset_t *, sigset_t *, sigset_t *); |
| 235 | |
Rich Felker | 2029114 | 2011-05-05 17:44:06 -0400 | [diff] [blame] | 236 | #define SA_NOMASK SA_NODEFER |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 237 | #define SA_ONESHOT SA_RESETHAND |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 238 | #endif |
| 239 | |
Rich Felker | 3eb9fea | 2011-02-15 15:10:00 -0500 | [diff] [blame] | 240 | #include <bits/signal.h> |
| 241 | |
Rich Felker | 81a5577 | 2011-09-21 22:25:31 -0400 | [diff] [blame] | 242 | #define SIG_ERR ((void (*)(int))-1) |
| 243 | #define SIG_DFL ((void (*)(int)) 0) |
| 244 | #define SIG_IGN ((void (*)(int)) 1) |
| 245 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 246 | typedef int sig_atomic_t; |
| 247 | |
| 248 | void (*signal(int, void (*)(int)))(int); |
| 249 | int raise(int); |
| 250 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 251 | #ifdef __cplusplus |
| 252 | } |
| 253 | #endif |
| 254 | |
| 255 | #endif |