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