| 1 | /* siginfo_t, sigevent and constants. Linux/MIPS version. |
|---|
| 2 | Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. |
|---|
| 3 | This file is part of the GNU C Library. |
|---|
| 4 | |
|---|
| 5 | The GNU C Library is free software; you can redistribute it and/or |
|---|
| 6 | modify it under the terms of the GNU Lesser General Public |
|---|
| 7 | License as published by the Free Software Foundation; either |
|---|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|---|
| 9 | |
|---|
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | Lesser General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU Lesser General Public |
|---|
| 16 | License along with the GNU C Library; if not, write to the Free |
|---|
| 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 18 | 02111-1307 USA. */ |
|---|
| 19 | |
|---|
| 20 | #if !defined _SIGNAL_H && !defined __need_siginfo_t \ |
|---|
| 21 | && !defined __need_sigevent_t |
|---|
| 22 | # error "Never include this file directly. Use <signal.h> instead" |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | #if (!defined __have_sigval_t \ |
|---|
| 26 | && (defined _SIGNAL_H || defined __need_siginfo_t \ |
|---|
| 27 | || defined __need_sigevent_t)) |
|---|
| 28 | # define __have_sigval_t 1 |
|---|
| 29 | |
|---|
| 30 | /* Type for data associated with a signal. */ |
|---|
| 31 | typedef union sigval |
|---|
| 32 | { |
|---|
| 33 | int sival_int; |
|---|
| 34 | void *sival_ptr; |
|---|
| 35 | } sigval_t; |
|---|
| 36 | #endif |
|---|
| 37 | |
|---|
| 38 | #if (!defined __have_siginfo_t \ |
|---|
| 39 | && (defined _SIGNAL_H || defined __need_siginfo_t)) |
|---|
| 40 | # define __have_siginfo_t 1 |
|---|
| 41 | |
|---|
| 42 | # define __SI_MAX_SIZE 128 |
|---|
| 43 | # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) |
|---|
| 44 | |
|---|
| 45 | typedef struct siginfo |
|---|
| 46 | { |
|---|
| 47 | int si_signo; /* Signal number. */ |
|---|
| 48 | int si_code; /* Signal code. */ |
|---|
| 49 | int si_errno; /* If non-zero, an errno value associated with |
|---|
| 50 | this signal, as defined in <errno.h>. */ |
|---|
| 51 | |
|---|
| 52 | union |
|---|
| 53 | { |
|---|
| 54 | int _pad[__SI_PAD_SIZE]; |
|---|
| 55 | |
|---|
| 56 | /* kill(). */ |
|---|
| 57 | struct |
|---|
| 58 | { |
|---|
| 59 | __pid_t si_pid; /* Sending process ID. */ |
|---|
| 60 | __uid_t si_uid; /* Real user ID of sending process. */ |
|---|
| 61 | } _kill; |
|---|
| 62 | |
|---|
| 63 | /* SIGCHLD. */ |
|---|
| 64 | struct |
|---|
| 65 | { |
|---|
| 66 | __pid_t si_pid; /* Which child. */ |
|---|
| 67 | __uid_t si_uid; /* Real user ID of sending process. */ |
|---|
| 68 | int si_status; /* Exit value or signal. */ |
|---|
| 69 | __clock_t si_utime; |
|---|
| 70 | __clock_t si_stime; |
|---|
| 71 | } _sigchld; |
|---|
| 72 | |
|---|
| 73 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ |
|---|
| 74 | struct |
|---|
| 75 | { |
|---|
| 76 | void *si_addr; /* Faulting insn/memory ref. */ |
|---|
| 77 | } _sigfault; |
|---|
| 78 | |
|---|
| 79 | /* SIGPOLL. */ |
|---|
| 80 | struct |
|---|
| 81 | { |
|---|
| 82 | int si_band; /* Band event for SIGPOLL. */ |
|---|
| 83 | int si_fd; |
|---|
| 84 | } _sigpoll; |
|---|
| 85 | |
|---|
| 86 | /* POSIX.1b timers. */ |
|---|
| 87 | struct |
|---|
| 88 | { |
|---|
| 89 | unsigned int _timer1; |
|---|
| 90 | unsigned int _timer2; |
|---|
| 91 | } _timer; |
|---|
| 92 | |
|---|
| 93 | /* POSIX.1b signals. */ |
|---|
| 94 | struct |
|---|
| 95 | { |
|---|
| 96 | __pid_t si_pid; /* Sending process ID. */ |
|---|
| 97 | __uid_t si_uid; /* Real user ID of sending process. */ |
|---|
| 98 | sigval_t si_sigval; /* Signal value. */ |
|---|
| 99 | } _rt; |
|---|
| 100 | } _sifields; |
|---|
| 101 | } siginfo_t; |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | /* X/Open requires some more fields with fixed names. */ |
|---|
| 105 | # define si_pid _sifields._kill.si_pid |
|---|
| 106 | # define si_uid _sifields._kill.si_uid |
|---|
| 107 | # define si_status _sifields._sigchld.si_status |
|---|
| 108 | # define si_utime _sifields._sigchld.si_utime |
|---|
| 109 | # define si_stime _sifields._sigchld.si_stime |
|---|
| 110 | # define si_value _sifields._rt.si_sigval |
|---|
| 111 | # define si_int _sifields._rt.si_sigval.sival_int |
|---|
| 112 | # define si_ptr _sifields._rt.si_sigval.sival_ptr |
|---|
| 113 | # define si_addr _sifields._sigfault.si_addr |
|---|
| 114 | # define si_band _sifields._sigpoll.si_band |
|---|
| 115 | # define si_fd _sifields._sigpoll.si_fd |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | /* Values for `si_code'. Positive values are reserved for kernel-generated |
|---|
| 119 | signals. */ |
|---|
| 120 | enum |
|---|
| 121 | { |
|---|
| 122 | SI_ASYNCNL = -6, /* Sent by asynch name lookup completion. */ |
|---|
| 123 | # define SI_ASYNCNL SI_ASYNCNL |
|---|
| 124 | SI_SIGIO, /* Sent by queued SIGIO. */ |
|---|
| 125 | # define SI_SIGIO SI_SIGIO |
|---|
| 126 | SI_MESGQ, /* Sent by real time mesq state change. */ |
|---|
| 127 | # define SI_MESGQ SI_MESGQ |
|---|
| 128 | SI_TIMER, /* Sent by real time mesq state change. */ |
|---|
| 129 | # define SI_TIMER SI_TIMER |
|---|
| 130 | SI_ASYNCIO, /* Sent by AIO completion. */ |
|---|
| 131 | # define SI_ASYNCIO SI_ASYNCIO |
|---|
| 132 | SI_QUEUE, /* Sent by sigqueue. */ |
|---|
| 133 | # define SI_QUEUE SI_QUEUE |
|---|
| 134 | SI_USER, /* Sent by kill, sigsend, raise. */ |
|---|
| 135 | # define SI_USER SI_USER |
|---|
| 136 | SI_KERNEL = 0x80 /* Send by kernel. */ |
|---|
| 137 | #define SI_KERNEL SI_KERNEL |
|---|
| 138 | }; |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | /* `si_code' values for SIGILL signal. */ |
|---|
| 142 | enum |
|---|
| 143 | { |
|---|
| 144 | ILL_ILLOPC = 1, /* Illegal opcode. */ |
|---|
| 145 | # define ILL_ILLOPC ILL_ILLOPC |
|---|
| 146 | ILL_ILLOPN, /* Illegal operand. */ |
|---|
| 147 | # define ILL_ILLOPN ILL_ILLOPN |
|---|
| 148 | ILL_ILLADR, /* Illegal addressing mode. */ |
|---|
| 149 | # define ILL_ILLADR ILL_ILLADR |
|---|
| 150 | ILL_ILLTRP, /* Illegal trap. */ |
|---|
| 151 | # define ILL_ILLTRP ILL_ILLTRP |
|---|
| 152 | ILL_PRVOPC, /* Privileged opcode. */ |
|---|
| 153 | # define ILL_PRVOPC ILL_PRVOPC |
|---|
| 154 | ILL_PRVREG, /* Privileged register. */ |
|---|
| 155 | # define ILL_PRVREG ILL_PRVREG |
|---|
| 156 | ILL_COPROC, /* Coprocessor error. */ |
|---|
| 157 | # define ILL_COPROC ILL_COPROC |
|---|
| 158 | ILL_BADSTK /* Internal stack error. */ |
|---|
| 159 | # define ILL_BADSTK ILL_BADSTK |
|---|
| 160 | }; |
|---|
| 161 | |
|---|
| 162 | /* `si_code' values for SIGFPE signal. */ |
|---|
| 163 | enum |
|---|
| 164 | { |
|---|
| 165 | FPE_INTDIV = 1, /* Integer divide by zero. */ |
|---|
| 166 | # define FPE_INTDIV FPE_INTDIV |
|---|
| 167 | FPE_INTOVF, /* Integer overflow. */ |
|---|
| 168 | # define FPE_INTOVF FPE_INTOVF |
|---|
| 169 | FPE_FLTDIV, /* Floating point divide by zero. */ |
|---|
| 170 | # define FPE_FLTDIV FPE_FLTDIV |
|---|
| 171 | FPE_FLTOVF, /* Floating point overflow. */ |
|---|
| 172 | # define FPE_FLTOVF FPE_FLTOVF |
|---|
| 173 | FPE_FLTUND, /* Floating point underflow. */ |
|---|
| 174 | # define FPE_FLTUND FPE_FLTUND |
|---|
| 175 | FPE_FLTRES, /* Floating point inexact result. */ |
|---|
| 176 | # define FPE_FLTRES FPE_FLTRES |
|---|
| 177 | FPE_FLTINV, /* Floating point invalid operation. */ |
|---|
| 178 | # define FPE_FLTINV FPE_FLTINV |
|---|
| 179 | FPE_FLTSUB /* Subscript out of range. */ |
|---|
| 180 | # define FPE_FLTSUB FPE_FLTSUB |
|---|
| 181 | }; |
|---|
| 182 | |
|---|
| 183 | /* `si_code' values for SIGSEGV signal. */ |
|---|
| 184 | enum |
|---|
| 185 | { |
|---|
| 186 | SEGV_MAPERR = 1, /* Address not mapped to object. */ |
|---|
| 187 | # define SEGV_MAPERR SEGV_MAPERR |
|---|
| 188 | SEGV_ACCERR /* Invalid permissions for mapped object. */ |
|---|
| 189 | # define SEGV_ACCERR SEGV_ACCERR |
|---|
| 190 | }; |
|---|
| 191 | |
|---|
| 192 | /* `si_code' values for SIGBUS signal. */ |
|---|
| 193 | enum |
|---|
| 194 | { |
|---|
| 195 | BUS_ADRALN = 1, /* Invalid address alignment. */ |
|---|
| 196 | # define BUS_ADRALN BUS_ADRALN |
|---|
| 197 | BUS_ADRERR, /* Non-existant physical address. */ |
|---|
| 198 | # define BUS_ADRERR BUS_ADRERR |
|---|
| 199 | BUS_OBJERR /* Object specific hardware error. */ |
|---|
| 200 | # define BUS_OBJERR BUS_OBJERR |
|---|
| 201 | }; |
|---|
| 202 | |
|---|
| 203 | /* `si_code' values for SIGTRAP signal. */ |
|---|
| 204 | enum |
|---|
| 205 | { |
|---|
| 206 | TRAP_BRKPT = 1, /* Process breakpoint. */ |
|---|
| 207 | # define TRAP_BRKPT TRAP_BRKPT |
|---|
| 208 | TRAP_TRACE /* Process trace trap. */ |
|---|
| 209 | # define TRAP_TRACE TRAP_TRACE |
|---|
| 210 | }; |
|---|
| 211 | |
|---|
| 212 | /* `si_code' values for SIGCHLD signal. */ |
|---|
| 213 | enum |
|---|
| 214 | { |
|---|
| 215 | CLD_EXITED = 1, /* Child has exited. */ |
|---|
| 216 | # define CLD_EXITED CLD_EXITED |
|---|
| 217 | CLD_KILLED, /* Child was killed. */ |
|---|
| 218 | # define CLD_KILLED CLD_KILLED |
|---|
| 219 | CLD_DUMPED, /* Child terminated abnormally. */ |
|---|
| 220 | # define CLD_DUMPED CLD_DUMPED |
|---|
| 221 | CLD_TRAPPED, /* Traced child has trapped. */ |
|---|
| 222 | # define CLD_TRAPPED CLD_TRAPPED |
|---|
| 223 | CLD_STOPPED, /* Child has stopped. */ |
|---|
| 224 | # define CLD_STOPPED CLD_STOPPED |
|---|
| 225 | CLD_CONTINUED /* Stopped child has continued. */ |
|---|
| 226 | # define CLD_CONTINUED CLD_CONTINUED |
|---|
| 227 | }; |
|---|
| 228 | |
|---|
| 229 | /* `si_code' values for SIGPOLL signal. */ |
|---|
| 230 | enum |
|---|
| 231 | { |
|---|
| 232 | POLL_IN = 1, /* Data input available. */ |
|---|
| 233 | # define POLL_IN POLL_IN |
|---|
| 234 | POLL_OUT, /* Output buffers available. */ |
|---|
| 235 | # define POLL_OUT POLL_OUT |
|---|
| 236 | POLL_MSG, /* Input message available. */ |
|---|
| 237 | # define POLL_MSG POLL_MSG |
|---|
| 238 | POLL_ERR, /* I/O error. */ |
|---|
| 239 | # define POLL_ERR POLL_ERR |
|---|
| 240 | POLL_PRI, /* High priority input available. */ |
|---|
| 241 | # define POLL_PRI POLL_PRI |
|---|
| 242 | POLL_HUP /* Device disconnected. */ |
|---|
| 243 | # define POLL_HUP POLL_HUP |
|---|
| 244 | }; |
|---|
| 245 | |
|---|
| 246 | # undef __need_siginfo_t |
|---|
| 247 | #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */ |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | #if (defined _SIGNAL_H || defined __need_sigevent_t) \ |
|---|
| 251 | && !defined __have_sigevent_t |
|---|
| 252 | # define __have_sigevent_t 1 |
|---|
| 253 | |
|---|
| 254 | /* Structure to transport application-defined values with signals. */ |
|---|
| 255 | # define __SIGEV_MAX_SIZE 64 |
|---|
| 256 | # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) |
|---|
| 257 | |
|---|
| 258 | /* Forward declaration of the `pthread_attr_t' type. */ |
|---|
| 259 | struct __pthread_attr_s; |
|---|
| 260 | |
|---|
| 261 | /* XXX This one might need to change!!! */ |
|---|
| 262 | typedef struct sigevent |
|---|
| 263 | { |
|---|
| 264 | sigval_t sigev_value; |
|---|
| 265 | int sigev_signo; |
|---|
| 266 | int sigev_notify; |
|---|
| 267 | |
|---|
| 268 | union |
|---|
| 269 | { |
|---|
| 270 | int _pad[__SIGEV_PAD_SIZE]; |
|---|
| 271 | |
|---|
| 272 | struct |
|---|
| 273 | { |
|---|
| 274 | void (*_function) (sigval_t); /* Function to start. */ |
|---|
| 275 | struct __pthread_attr_s *_attribute; /* Really pthread_attr_t. */ |
|---|
| 276 | } _sigev_thread; |
|---|
| 277 | } _sigev_un; |
|---|
| 278 | } sigevent_t; |
|---|
| 279 | |
|---|
| 280 | /* POSIX names to access some of the members. */ |
|---|
| 281 | # define sigev_notify_function _sigev_un._sigev_thread._function |
|---|
| 282 | # define sigev_notify_attributes _sigev_un._sigev_thread._attribute |
|---|
| 283 | |
|---|
| 284 | /* `sigev_notify' values. */ |
|---|
| 285 | enum |
|---|
| 286 | { |
|---|
| 287 | SIGEV_SIGNAL = 0, /* Notify via signal. */ |
|---|
| 288 | # define SIGEV_SIGNAL SIGEV_SIGNAL |
|---|
| 289 | SIGEV_NONE, /* Other notification: meaningless. */ |
|---|
| 290 | # define SIGEV_NONE SIGEV_NONE |
|---|
| 291 | SIGEV_CALLBACK, /* Deliver via thread creation. */ |
|---|
| 292 | # define SIGEV_CALLBACK SIGEV_CALLBACK |
|---|
| 293 | SIGEV_THREAD /* Deliver via thread creation. */ |
|---|
| 294 | # define SIGEV_THREAD SIGEV_THREAD |
|---|
| 295 | }; |
|---|
| 296 | |
|---|
| 297 | #endif /* have _SIGNAL_H. */ |
|---|