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 | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 8 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 9 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 10 | |
Rich Felker | 03a8362 | 2011-09-20 10:58:18 -0400 | [diff] [blame] | 11 | #ifdef _GNU_SOURCE |
| 12 | #define __siginfo siginfo |
| 13 | #endif |
| 14 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 15 | #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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 20 | #define __NEED_pthread_attr_t |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 21 | #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 Felker | 81a5577 | 2011-09-21 22:25:31 -0400 | [diff] [blame] | 28 | #define SIG_HOLD ((void (*)(int)) 2) |
| 29 | |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 30 | #define SIG_BLOCK 0 |
| 31 | #define SIG_UNBLOCK 1 |
| 32 | #define SIG_SETMASK 2 |
| 33 | |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 34 | #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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 76 | struct sigaction { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 77 | 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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 88 | typedef struct { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 89 | void *ss_sp; |
| 90 | int ss_flags; |
| 91 | size_t ss_size; |
| 92 | } stack_t; |
| 93 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 94 | union sigval { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 95 | int sival_int; |
| 96 | void *sival_ptr; |
| 97 | }; |
| 98 | |
Rich Felker | 03a8362 | 2011-09-20 10:58:18 -0400 | [diff] [blame] | 99 | struct __siginfo { |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 100 | 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 Felker | 8c07f6e | 2011-09-19 22:27:02 -0400 | [diff] [blame] | 137 | #define si_ptr __si_fields.__rt.si_sigval.sival_ptr |
| 138 | #define si_int __si_fields.__rt.si_sigval.sival_int |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 139 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 140 | struct 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 Felker | 7f54715 | 2011-06-16 17:11:35 -0400 | [diff] [blame] | 146 | char __pad[56-3*sizeof(long)]; |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | #define SIGEV_SIGNAL 0 |
| 150 | #define SIGEV_NONE 1 |
| 151 | #define SIGEV_THREAD 2 |
| 152 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 153 | int __libc_current_sigrtmin(void); |
| 154 | int __libc_current_sigrtmax(void); |
| 155 | |
| 156 | #define SIGRTMIN (__libc_current_sigrtmin()) |
| 157 | #define SIGRTMAX (__libc_current_sigrtmax()) |
| 158 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 159 | int kill(pid_t, int); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 160 | |
| 161 | int sigemptyset(sigset_t *); |
| 162 | int sigfillset(sigset_t *); |
| 163 | int sigaddset(sigset_t *, int); |
| 164 | int sigdelset(sigset_t *, int); |
| 165 | int sigismember(const sigset_t *, int); |
| 166 | |
| 167 | int sigprocmask(int, const sigset_t *, sigset_t *); |
| 168 | int sigsuspend(const sigset_t *); |
| 169 | int sigaction(int, const struct sigaction *, struct sigaction *); |
| 170 | int sigpending(sigset_t *); |
| 171 | int sigwait(const sigset_t *, int *); |
| 172 | int sigwaitinfo(const sigset_t *, siginfo_t *); |
| 173 | int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); |
| 174 | int sigqueue(pid_t, int, const union sigval); |
| 175 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 176 | int pthread_sigmask(int, const sigset_t *, sigset_t *); |
| 177 | int pthread_kill(pthread_t, int); |
| 178 | |
Rich Felker | adb7093 | 2011-09-02 14:25:43 -0400 | [diff] [blame] | 179 | void psiginfo(const siginfo_t *, const char *); |
| 180 | void psignal(int, const char *); |
| 181 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 182 | #endif |
| 183 | |
| 184 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 185 | int killpg(pid_t, int); |
| 186 | int sigaltstack(const stack_t *, stack_t *); |
| 187 | int sighold(int); |
| 188 | int sigignore(int); |
| 189 | int siginterrupt(int, int); |
| 190 | int sigpause(int); |
| 191 | int sigrelse(int); |
| 192 | void (*sigset(int, void (*)(int)))(int); |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 193 | #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 Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 205 | #endif |
| 206 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 207 | #ifdef _GNU_SOURCE |
Rich Felker | 0f5b435 | 2011-04-13 08:45:28 -0400 | [diff] [blame] | 208 | typedef void (*sighandler_t)(int); |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 209 | void (*bsd_signal(int, void (*)(int)))(int); |
Rich Felker | fb80e04 | 2011-09-12 00:00:30 -0400 | [diff] [blame] | 210 | int sigisemptyset(const sigset_t *); |
Rich Felker | 2029114 | 2011-05-05 17:44:06 -0400 | [diff] [blame] | 211 | #define SA_NOMASK SA_NODEFER |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 212 | #define SA_ONESHOT SA_RESETHAND |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 213 | #endif |
| 214 | |
Rich Felker | 3eb9fea | 2011-02-15 15:10:00 -0500 | [diff] [blame] | 215 | #include <bits/signal.h> |
| 216 | |
Rich Felker | 81a5577 | 2011-09-21 22:25:31 -0400 | [diff] [blame] | 217 | #define SIG_ERR ((void (*)(int))-1) |
| 218 | #define SIG_DFL ((void (*)(int)) 0) |
| 219 | #define SIG_IGN ((void (*)(int)) 1) |
| 220 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 221 | typedef int sig_atomic_t; |
| 222 | |
| 223 | void (*signal(int, void (*)(int)))(int); |
| 224 | int raise(int); |
| 225 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 226 | #ifdef __cplusplus |
| 227 | } |
| 228 | #endif |
| 229 | |
| 230 | #endif |