initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / asm-generic / siginfo.h
blob3a3f35d75af27d54673ef79730a2b791956887f7
1 #ifndef _ASM_GENERIC_SIGINFO_H
2 #define _ASM_GENERIC_SIGINFO_H
4 #include <linux/compiler.h>
5 #include <linux/types.h>
6 #include <linux/resource.h>
8 typedef union sigval {
9 int sival_int;
10 void __user *sival_ptr;
11 } sigval_t;
14 * This is the size (including padding) of the part of the
15 * struct siginfo that is before the union.
17 #ifndef __ARCH_SI_PREAMBLE_SIZE
18 #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
19 #endif
21 #define SI_MAX_SIZE 128
22 #ifndef SI_PAD_SIZE
23 #define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
24 #endif
26 #ifndef __ARCH_SI_UID_T
27 #define __ARCH_SI_UID_T uid_t
28 #endif
31 * The default "si_band" type is "long", as specified by POSIX.
32 * However, some architectures want to override this to "int"
33 * for historical compatibility reasons, so we allow that.
35 #ifndef __ARCH_SI_BAND_T
36 #define __ARCH_SI_BAND_T long
37 #endif
39 #ifndef HAVE_ARCH_SIGINFO_T
41 typedef struct siginfo {
42 int si_signo;
43 int si_errno;
44 int si_code;
46 union {
47 int _pad[SI_PAD_SIZE];
49 /* kill() */
50 struct {
51 pid_t _pid; /* sender's pid */
52 __ARCH_SI_UID_T _uid; /* sender's uid */
53 } _kill;
55 /* POSIX.1b timers */
56 struct {
57 timer_t _tid; /* timer id */
58 int _overrun; /* overrun count */
59 char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
60 sigval_t _sigval; /* same as below */
61 int _sys_private; /* not to be passed to user */
62 } _timer;
64 /* POSIX.1b signals */
65 struct {
66 pid_t _pid; /* sender's pid */
67 __ARCH_SI_UID_T _uid; /* sender's uid */
68 sigval_t _sigval;
69 } _rt;
71 /* SIGCHLD */
72 struct {
73 pid_t _pid; /* which child */
74 __ARCH_SI_UID_T _uid; /* sender's uid */
75 int _status; /* exit code */
76 clock_t _utime;
77 clock_t _stime;
78 } _sigchld;
80 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
81 struct {
82 void __user *_addr; /* faulting insn/memory ref. */
83 #ifdef __ARCH_SI_TRAPNO
84 int _trapno; /* TRAP # which caused the signal */
85 #endif
86 } _sigfault;
88 /* SIGPOLL */
89 struct {
90 __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
91 int _fd;
92 } _sigpoll;
93 } _sifields;
94 } siginfo_t;
96 #endif
99 * How these fields are to be accessed.
101 #define si_pid _sifields._kill._pid
102 #define si_uid _sifields._kill._uid
103 #define si_tid _sifields._timer._tid
104 #define si_overrun _sifields._timer._overrun
105 #define si_sys_private _sifields._timer._sys_private
106 #define si_status _sifields._sigchld._status
107 #define si_utime _sifields._sigchld._utime
108 #define si_stime _sifields._sigchld._stime
109 #define si_value _sifields._rt._sigval
110 #define si_int _sifields._rt._sigval.sival_int
111 #define si_ptr _sifields._rt._sigval.sival_ptr
112 #define si_addr _sifields._sigfault._addr
113 #ifdef __ARCH_SI_TRAPNO
114 #define si_trapno _sifields._sigfault._trapno
115 #endif
116 #define si_band _sifields._sigpoll._band
117 #define si_fd _sifields._sigpoll._fd
119 #ifdef __KERNEL__
120 #define __SI_MASK 0xffff0000u
121 #define __SI_KILL (0 << 16)
122 #define __SI_TIMER (1 << 16)
123 #define __SI_POLL (2 << 16)
124 #define __SI_FAULT (3 << 16)
125 #define __SI_CHLD (4 << 16)
126 #define __SI_RT (5 << 16)
127 #define __SI_MESGQ (6 << 16)
128 #define __SI_CODE(T,N) ((T) | ((N) & 0xffff))
129 #else
130 #define __SI_KILL 0
131 #define __SI_TIMER 0
132 #define __SI_POLL 0
133 #define __SI_FAULT 0
134 #define __SI_CHLD 0
135 #define __SI_RT 0
136 #define __SI_MESGQ 0
137 #define __SI_CODE(T,N) (N)
138 #endif
141 * si_code values
142 * Digital reserves positive values for kernel-generated signals.
144 #define SI_USER 0 /* sent by kill, sigsend, raise */
145 #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
146 #define SI_QUEUE -1 /* sent by sigqueue */
147 #define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
148 #define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */
149 #define SI_ASYNCIO -4 /* sent by AIO completion */
150 #define SI_SIGIO -5 /* sent by queued SIGIO */
151 #define SI_TKILL -6 /* sent by tkill system call */
152 #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
154 #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
155 #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
157 #ifndef HAVE_ARCH_SI_CODES
159 * SIGILL si_codes
161 #define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */
162 #define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */
163 #define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */
164 #define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */
165 #define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */
166 #define ILL_PRVREG (__SI_FAULT|6) /* privileged register */
167 #define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */
168 #define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */
169 #define NSIGILL 8
172 * SIGFPE si_codes
174 #define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */
175 #define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */
176 #define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */
177 #define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */
178 #define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */
179 #define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */
180 #define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */
181 #define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */
182 #define NSIGFPE 8
185 * SIGSEGV si_codes
187 #define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
188 #define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */
189 #define NSIGSEGV 2
192 * SIGBUS si_codes
194 #define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
195 #define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */
196 #define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
197 #define NSIGBUS 3
200 * SIGTRAP si_codes
202 #define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */
203 #define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */
204 #define NSIGTRAP 2
207 * SIGCHLD si_codes
209 #define CLD_EXITED (__SI_CHLD|1) /* child has exited */
210 #define CLD_KILLED (__SI_CHLD|2) /* child was killed */
211 #define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */
212 #define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */
213 #define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */
214 #define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */
215 #define NSIGCHLD 6
218 * SIGPOLL si_codes
220 #define POLL_IN (__SI_POLL|1) /* data input available */
221 #define POLL_OUT (__SI_POLL|2) /* output buffers available */
222 #define POLL_MSG (__SI_POLL|3) /* input message available */
223 #define POLL_ERR (__SI_POLL|4) /* i/o error */
224 #define POLL_PRI (__SI_POLL|5) /* high priority input available */
225 #define POLL_HUP (__SI_POLL|6) /* device disconnected */
226 #define NSIGPOLL 6
228 #endif
231 * sigevent definitions
233 * It seems likely that SIGEV_THREAD will have to be handled from
234 * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
235 * thread manager then catches and does the appropriate nonsense.
236 * However, everything is written out here so as to not get lost.
238 #define SIGEV_SIGNAL 0 /* notify via signal */
239 #define SIGEV_NONE 1 /* other notification: meaningless */
240 #define SIGEV_THREAD 2 /* deliver via thread creation */
241 #define SIGEV_THREAD_ID 4 /* deliver to thread */
243 #define SIGEV_MAX_SIZE 64
244 #ifndef SIGEV_PAD_SIZE
245 #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
246 #endif
248 #ifndef HAVE_ARCH_SIGEVENT_T
250 typedef struct sigevent {
251 sigval_t sigev_value;
252 int sigev_signo;
253 int sigev_notify;
254 union {
255 int _pad[SIGEV_PAD_SIZE];
256 int _tid;
258 struct {
259 void (*_function)(sigval_t);
260 void *_attribute; /* really pthread_attr_t */
261 } _sigev_thread;
262 } _sigev_un;
263 } sigevent_t;
265 #endif
267 #define sigev_notify_function _sigev_un._sigev_thread._function
268 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
269 #define sigev_notify_thread_id _sigev_un._tid
271 #ifdef __KERNEL__
273 struct siginfo;
274 void do_schedule_next_timer(struct siginfo *info);
276 #ifndef HAVE_ARCH_COPY_SIGINFO
278 #include <linux/string.h>
280 static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
282 if (from->si_code < 0)
283 memcpy(to, from, sizeof(*to));
284 else
285 /* _sigchld is currently the largest know union member */
286 memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld));
289 #endif
291 extern int copy_siginfo_to_user(struct siginfo __user *to, struct siginfo *from);
293 #endif /* __KERNEL__ */
295 #endif