1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / siginfo.h
blobe73a1aaca1b2b19cad0d76c64e0525bea0120ad4
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #ifndef _SYS_SIGINFO_H
31 #define _SYS_SIGINFO_H
33 #include <sys/feature_tests.h>
34 #include <sys/types.h>
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
41 defined(__EXTENSIONS__)
44 * The union sigval is also defined in <time.h> as per X/Open and
45 * POSIX requirements.
47 #ifndef _SIGVAL
48 #define _SIGVAL
49 union sigval {
50 int sival_int; /* integer value */
51 void *sival_ptr; /* pointer value */
53 #endif /* _SIGVAL */
55 #if defined(_SYSCALL32)
57 /* Kernel view of user ILP32 sigval */
59 union sigval32 {
60 int32_t sival_int; /* integer value */
61 caddr32_t sival_ptr; /* pointer value */
64 #endif /* _SYSCALL32 */
66 #else /* needed in siginfo_t structure */
68 union __sigval {
69 int __sival_int; /* integer value */
70 void *__sival_ptr; /* pointer value */
73 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
75 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
76 defined(__EXTENSIONS__)
79 * The sigevent structure is also defined in <time.h> as per X/Open and
80 * POSIX requirements.
82 #ifndef _SIGEVENT
83 #define _SIGEVENT
84 struct sigevent {
85 int sigev_notify; /* notification mode */
86 int sigev_signo; /* signal number */
87 union sigval sigev_value; /* signal value */
88 void (*sigev_notify_function)(union sigval);
89 pthread_attr_t *sigev_notify_attributes;
90 int __sigev_pad2;
92 #endif /* _SIGEVENT */
94 /* values of sigev_notify */
95 #define SIGEV_NONE 1 /* no notification */
96 #define SIGEV_SIGNAL 2 /* queued signal notification */
97 #define SIGEV_THREAD 3 /* call back from another thread */
98 #define SIGEV_PORT 4 /* use event port for notification */
100 #if defined(_SYSCALL32)
102 /* Kernel view of user ILP32 sigevent */
104 struct sigevent32 {
105 int32_t sigev_notify; /* notification mode */
106 int32_t sigev_signo; /* signal number */
107 union sigval32 sigev_value; /* signal value */
108 caddr32_t sigev_notify_function;
109 caddr32_t sigev_notify_attributes;
110 int32_t __sigev_pad2;
113 #endif /* _SYSCALL32 */
115 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
117 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
118 defined(__EXTENSIONS__)
120 * negative signal codes are reserved for future use for user generated
121 * signals
124 #define SI_FROMUSER(sip) ((sip)->si_code <= 0)
125 #define SI_FROMKERNEL(sip) ((sip)->si_code > 0)
127 #define SI_NOINFO 32767 /* no signal information */
128 #define SI_DTRACE 2050 /* kernel generated signal via DTrace action */
129 #define SI_RCTL 2049 /* kernel generated signal via rctl action */
130 #define SI_USER 0 /* user generated signal via kill() */
131 #define SI_LWP (-1) /* user generated signal via lwp_kill() */
132 #define SI_QUEUE (-2) /* user generated signal via sigqueue() */
133 #define SI_TIMER (-3) /* from timer expiration */
134 #define SI_ASYNCIO (-4) /* from asynchronous I/O completion */
135 #define SI_MESGQ (-5) /* from message arrival */
136 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
138 #if !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) || defined(__EXTENSIONS__)
140 * Get the machine dependent signal codes (SIGILL, SIGFPE, SIGSEGV, and
141 * SIGBUS) from <sys/machsig.h>
144 #include <sys/machsig.h>
147 * SIGTRAP signal codes
150 #define TRAP_BRKPT 1 /* breakpoint trap */
151 #define TRAP_TRACE 2 /* trace trap */
152 #define TRAP_RWATCH 3 /* read access watchpoint trap */
153 #define TRAP_WWATCH 4 /* write access watchpoint trap */
154 #define TRAP_XWATCH 5 /* execute access watchpoint trap */
155 #define TRAP_DTRACE 6 /* problem with fasttrap DTrace provider */
156 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
157 #define NSIGTRAP 6
158 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
161 * SIGCLD signal codes
164 #define CLD_EXITED 1 /* child has exited */
165 #define CLD_KILLED 2 /* child was killed */
166 #define CLD_DUMPED 3 /* child has coredumped */
167 #define CLD_TRAPPED 4 /* traced child has stopped */
168 #define CLD_STOPPED 5 /* child has stopped on signal */
169 #define CLD_CONTINUED 6 /* stopped child has continued */
171 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
172 #define NSIGCLD 6
173 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
176 * SIGPOLL signal codes
179 #define POLL_IN 1 /* input available */
180 #define POLL_OUT 2 /* output possible */
181 #define POLL_MSG 3 /* message available */
182 #define POLL_ERR 4 /* I/O error */
183 #define POLL_PRI 5 /* high priority input available */
184 #define POLL_HUP 6 /* device disconnected */
186 #if !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__)
187 #define NSIGPOLL 6
188 #endif /* !defined(_XOPEN_SOURCE) || defined(__EXTENSIONS__) */
190 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XPG4_2) ... */
192 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
194 * SIGPROF signal codes
197 #define PROF_SIG 1 /* have to set code non-zero */
198 #define NSIGPROF 1
200 #endif /* !defined(__XOPEN_OR_POSIX) || defined (__EXTENSIONS__) */
202 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
203 defined(__EXTENSIONS__)
205 #ifdef _LP64
206 #define SI_MAXSZ 256
207 #define SI_PAD ((SI_MAXSZ / sizeof (int)) - 4)
208 #else
209 #define SI_MAXSZ 128
210 #define SI_PAD ((SI_MAXSZ / sizeof (int)) - 3)
211 #endif
214 * Inclusion of <sys/time_impl.h> is needed for the declaration of
215 * timestruc_t. However, since inclusion of <sys/time_impl.h> results
216 * in X/Open and POSIX namespace pollution, the definition for
217 * timestruct_t has been duplicated in a standards namespace safe header
218 * <sys/time_std_impl.h>. In <sys/time_std_impl.h>, the structure
219 * name, tag, and member names, as well as the type itself, all have
220 * leading underscores to protect namespace.
222 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
223 #include <sys/time_impl.h>
224 #else
225 #include <sys/time_std_impl.h>
226 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
229 * The inclusion of <sys/types.h> is needed for definitions of pid_t, etc.
230 * Placement here is due to a dependency in <sys/select.h> which is included
231 * by <sys/types.h> for the sigevent structure. Hence this inclusion must
232 * follow that definition.
234 #include <sys/types.h> /* for definitions of pid_t, etc. */
236 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
237 typedef struct siginfo { /* pollutes POSIX/XOPEN namespace */
238 #else
239 typedef struct {
240 #endif
241 int si_signo; /* signal from signal.h */
242 int si_code; /* code from above */
243 int si_errno; /* error from errno.h */
244 #ifdef _LP64
245 int si_pad; /* _LP64 union starts on an 8-byte boundary */
246 #endif
247 union {
249 int __pad[SI_PAD]; /* for future growth */
251 struct { /* kill(), SIGCLD, siqqueue() */
252 pid_t __pid; /* process ID */
253 union {
254 struct {
255 uid_t __uid;
256 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
257 defined(__EXTENSIONS__)
258 union sigval __value;
259 #else
260 union __sigval __value;
261 #endif
262 } __kill;
263 struct {
264 clock_t __utime;
265 int __status;
266 clock_t __stime;
267 } __cld;
268 } __pdata;
269 ctid_t __ctid; /* contract ID */
270 zoneid_t __zoneid; /* zone ID */
271 } __proc;
273 struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */
274 void *__addr; /* faulting address */
275 int __trapno; /* illegal trap number */
276 caddr_t __pc; /* instruction address */
277 } __fault;
279 struct { /* SIGPOLL, SIGXFSZ */
280 /* fd not currently available for SIGPOLL */
281 int __fd; /* file descriptor */
282 long __band;
283 } __file;
285 struct { /* SIGPROF */
286 caddr_t __faddr; /* last fault address */
287 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
288 timestruc_t __tstamp; /* real time stamp */
289 #else
290 _timestruc_t __tstamp; /* real time stamp */
291 #endif
292 short __syscall; /* current syscall */
293 char __nsysarg; /* number of arguments */
294 char __fault; /* last fault type */
295 long __sysarg[8]; /* syscall arguments */
296 int __mstate[10]; /* see <sys/msacct.h> */
297 } __prof;
299 struct { /* SI_RCTL */
300 int32_t __entity; /* type of entity exceeding */
301 } __rctl;
302 } __data;
304 } siginfo_t;
306 #if defined(_SYSCALL32)
308 /* Kernel view of user ILP32 siginfo struct */
310 #define SI32_MAXSZ 128
311 #define SI32_PAD ((SI32_MAXSZ / sizeof (int32_t)) - 3)
313 typedef struct siginfo32 {
315 int32_t si_signo; /* signal from signal.h */
316 int32_t si_code; /* code from above */
317 int32_t si_errno; /* error from errno.h */
319 union {
321 int32_t __pad[SI32_PAD]; /* for future growth */
323 struct { /* kill(), SIGCLD, siqqueue() */
324 pid32_t __pid; /* process ID */
325 union {
326 struct {
327 uid32_t __uid;
328 union sigval32 __value;
329 } __kill;
330 struct {
331 clock32_t __utime;
332 int32_t __status;
333 clock32_t __stime;
334 } __cld;
335 } __pdata;
336 id32_t __ctid; /* contract ID */
337 id32_t __zoneid; /* zone ID */
338 } __proc;
340 struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */
341 caddr32_t __addr; /* faulting address */
342 int32_t __trapno; /* illegal trap number */
343 caddr32_t __pc; /* instruction address */
344 } __fault;
346 struct { /* SIGPOLL, SIGXFSZ */
347 /* fd not currently available for SIGPOLL */
348 int32_t __fd; /* file descriptor */
349 int32_t __band;
350 } __file;
352 struct { /* SIGPROF */
353 caddr32_t __faddr; /* last fault address */
354 timestruc32_t __tstamp; /* real time stamp */
355 int16_t __syscall; /* current syscall */
356 int8_t __nsysarg; /* number of arguments */
357 int8_t __fault; /* last fault type */
358 int32_t __sysarg[8]; /* syscall arguments */
359 int32_t __mstate[10]; /* see <sys/msacct.h> */
360 } __prof;
362 struct { /* SI_RCTL */
363 int32_t __entity; /* type of entity exceeding */
364 } __rctl;
366 } __data;
368 } siginfo32_t;
370 #endif /* _SYSCALL32 */
373 * XXX -- internal version is identical to siginfo_t but without the padding.
374 * This must be maintained in sync with it.
377 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
379 typedef struct k_siginfo {
380 int si_signo; /* signal from signal.h */
381 int si_code; /* code from above */
382 int si_errno; /* error from errno.h */
383 #ifdef _LP64
384 int si_pad; /* _LP64 union starts on an 8-byte boundary */
385 #endif
386 union {
387 struct { /* kill(), SIGCLD, siqqueue() */
388 pid_t __pid; /* process ID */
389 union {
390 struct {
391 uid_t __uid;
392 union sigval __value;
393 } __kill;
394 struct {
395 clock_t __utime;
396 int __status;
397 clock_t __stime;
398 } __cld;
399 } __pdata;
400 ctid_t __ctid; /* contract ID */
401 zoneid_t __zoneid; /* zone ID */
402 } __proc;
404 struct { /* SIGSEGV, SIGBUS, SIGILL, SIGTRAP, SIGFPE */
405 void *__addr; /* faulting address */
406 int __trapno; /* illegal trap number */
407 caddr_t __pc; /* instruction address */
408 } __fault;
410 struct { /* SIGPOLL, SIGXFSZ */
411 /* fd not currently available for SIGPOLL */
412 int __fd; /* file descriptor */
413 long __band;
414 } __file;
416 struct { /* SIGPROF */
417 caddr_t __faddr; /* last fault address */
419 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
420 timestruc_t __tstamp; /* real time stamp */
421 #else
422 _timestruc_t __tstamp; /* real time stamp */
423 #endif
424 short __syscall; /* current syscall */
425 char __nsysarg; /* number of arguments */
426 char __fault; /* last fault type */
427 /* these are omitted to keep k_siginfo_t small */
428 /* long __sysarg[8]; */
429 /* int __mstate[10]; */
430 } __prof;
432 struct { /* SI_RCTL */
433 int32_t __entity; /* type of entity exceeding */
434 } __rctl;
436 } __data;
438 } k_siginfo_t;
440 typedef struct sigqueue {
441 struct sigqueue *sq_next;
442 k_siginfo_t sq_info;
443 void (*sq_func)(struct sigqueue *); /* destructor function */
444 void *sq_backptr; /* pointer to the data structure */
445 /* associated by sq_func() */
446 int sq_external; /* comes from outside the contract */
447 } sigqueue_t;
449 /* indication whether to queue the signal or not */
450 #define SI_CANQUEUE(c) ((c) <= SI_QUEUE)
452 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
454 #define si_pid __data.__proc.__pid
455 #define si_ctid __data.__proc.__ctid
456 #define si_zoneid __data.__proc.__zoneid
457 #define si_status __data.__proc.__pdata.__cld.__status
458 #define si_stime __data.__proc.__pdata.__cld.__stime
459 #define si_utime __data.__proc.__pdata.__cld.__utime
460 #define si_uid __data.__proc.__pdata.__kill.__uid
461 #define si_value __data.__proc.__pdata.__kill.__value
462 #define si_addr __data.__fault.__addr
463 #define si_trapno __data.__fault.__trapno
464 #define si_trapafter __data.__fault.__trapno
465 #define si_pc __data.__fault.__pc
466 #define si_fd __data.__file.__fd
467 #define si_band __data.__file.__band
468 #define si_tstamp __data.__prof.__tstamp
469 #define si_syscall __data.__prof.__syscall
470 #define si_nsysarg __data.__prof.__nsysarg
471 #define si_sysarg __data.__prof.__sysarg
472 #define si_fault __data.__prof.__fault
473 #define si_faddr __data.__prof.__faddr
474 #define si_mstate __data.__prof.__mstate
475 #define si_entity __data.__rctl.__entity
477 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) ... */
480 #if defined(_SYSCALL32_IMPL)
482 extern void siginfo_kto32(const k_siginfo_t *, siginfo32_t *);
483 extern void siginfo_32tok(const siginfo32_t *, k_siginfo_t *);
485 #endif /* _SYSCALL32_IMPL */
487 #ifdef __cplusplus
489 #endif
491 #endif /* _SYS_SIGINFO_H */