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 | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 11 | #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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 16 | #define __NEED_pthread_attr_t |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 17 | #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 Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 24 | #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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 75 | struct sigaction { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 76 | 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 Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 87 | typedef struct { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 88 | void *ss_sp; |
| 89 | int ss_flags; |
| 90 | size_t ss_size; |
| 91 | } stack_t; |
| 92 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 93 | union sigval { |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 94 | int sival_int; |
| 95 | void *sival_ptr; |
| 96 | }; |
| 97 | |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 98 | #ifdef _GNU_SOURCE |
| 99 | struct siginfo |
| 100 | #else |
| 101 | struct __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 Felker | 8c07f6e | 2011-09-19 22:27:02 -0400 | [diff] [blame^] | 141 | #define si_ptr __si_fields.__rt.si_sigval.sival_ptr |
| 142 | #define si_int __si_fields.__rt.si_sigval.sival_int |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 143 | |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 144 | struct 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 Felker | 7f54715 | 2011-06-16 17:11:35 -0400 | [diff] [blame] | 150 | char __pad[56-3*sizeof(long)]; |
Rich Felker | 80c4dcd | 2011-03-29 13:01:25 -0400 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | #define SIGEV_SIGNAL 0 |
| 154 | #define SIGEV_NONE 1 |
| 155 | #define SIGEV_THREAD 2 |
| 156 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 157 | int __libc_current_sigrtmin(void); |
| 158 | int __libc_current_sigrtmax(void); |
| 159 | |
| 160 | #define SIGRTMIN (__libc_current_sigrtmin()) |
| 161 | #define SIGRTMAX (__libc_current_sigrtmax()) |
| 162 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 163 | int kill(pid_t, int); |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 164 | |
| 165 | int sigemptyset(sigset_t *); |
| 166 | int sigfillset(sigset_t *); |
| 167 | int sigaddset(sigset_t *, int); |
| 168 | int sigdelset(sigset_t *, int); |
| 169 | int sigismember(const sigset_t *, int); |
| 170 | |
| 171 | int sigprocmask(int, const sigset_t *, sigset_t *); |
| 172 | int sigsuspend(const sigset_t *); |
| 173 | int sigaction(int, const struct sigaction *, struct sigaction *); |
| 174 | int sigpending(sigset_t *); |
| 175 | int sigwait(const sigset_t *, int *); |
| 176 | int sigwaitinfo(const sigset_t *, siginfo_t *); |
| 177 | int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *); |
| 178 | int sigqueue(pid_t, int, const union sigval); |
| 179 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 180 | int pthread_sigmask(int, const sigset_t *, sigset_t *); |
| 181 | int pthread_kill(pthread_t, int); |
| 182 | |
Rich Felker | adb7093 | 2011-09-02 14:25:43 -0400 | [diff] [blame] | 183 | void psiginfo(const siginfo_t *, const char *); |
| 184 | void psignal(int, const char *); |
| 185 | |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 186 | #endif |
| 187 | |
| 188 | #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) |
| 189 | int killpg(pid_t, int); |
| 190 | int sigaltstack(const stack_t *, stack_t *); |
| 191 | int sighold(int); |
| 192 | int sigignore(int); |
| 193 | int siginterrupt(int, int); |
| 194 | int sigpause(int); |
| 195 | int sigrelse(int); |
| 196 | void (*sigset(int, void (*)(int)))(int); |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 197 | #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 Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 209 | #endif |
| 210 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 211 | #ifdef _GNU_SOURCE |
Rich Felker | 0f5b435 | 2011-04-13 08:45:28 -0400 | [diff] [blame] | 212 | typedef void (*sighandler_t)(int); |
Rich Felker | 1322cb8 | 2011-02-14 20:33:54 -0500 | [diff] [blame] | 213 | void (*bsd_signal(int, void (*)(int)))(int); |
Rich Felker | fb80e04 | 2011-09-12 00:00:30 -0400 | [diff] [blame] | 214 | int sigisemptyset(const sigset_t *); |
Rich Felker | 2029114 | 2011-05-05 17:44:06 -0400 | [diff] [blame] | 215 | #define SA_NOMASK SA_NODEFER |
Rich Felker | f780ac5 | 2011-09-19 20:02:12 -0400 | [diff] [blame] | 216 | #define SA_ONESHOT SA_RESETHAND |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 217 | #endif |
| 218 | |
Rich Felker | 3eb9fea | 2011-02-15 15:10:00 -0500 | [diff] [blame] | 219 | #include <bits/signal.h> |
| 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 |