1 #ifndef _ASM_IA64_SIGINFO_H
2 #define _ASM_IA64_SIGINFO_H
3
4 /*
5 * Based on <asm-i386/siginfo.h>.
6 *
7 * Modified 1998-2002
8 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
9 */
10
11 #include <linux/types.h>
12
13 typedef union sigval {
14 int sival_int;
15 void *sival_ptr;
16 } sigval_t;
17
18 #define SI_MAX_SIZE 128
19 #define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 4)
20
21 typedef struct siginfo {
22 int si_signo;
23 int si_errno;
24 int si_code;
25 int __pad0;
26
27 union {
28 int _pad[SI_PAD_SIZE];
29
30 /* kill() */
31 struct {
32 pid_t _pid; /* sender's pid */
33 uid_t _uid; /* sender's uid */
34 } _kill;
35
36 /* POSIX.1b timers */
37 struct {
38 unsigned int _timer1;
39 unsigned int _timer2;
40 } _timer;
41
42 /* POSIX.1b signals */
43 struct {
44 pid_t _pid; /* sender's pid */
45 uid_t _uid; /* sender's uid */
46 sigval_t _sigval;
47 } _rt;
48
49 /* SIGCHLD */
50 struct {
51 pid_t _pid; /* which child */
52 uid_t _uid; /* sender's uid */
53 int _status; /* exit code */
54 clock_t _utime;
55 clock_t _stime;
56 } _sigchld;
57
58 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
59 struct {
60 void *_addr; /* faulting insn/memory ref. */
61 int _imm; /* immediate value for "break" */
62 unsigned int _flags; /* see below */
63 unsigned long _isr; /* isr */
64 } _sigfault;
65
66 /* SIGPOLL */
67 struct {
68 long _band; /* POLL_IN, POLL_OUT, POLL_MSG (XPG requires a "long") */
69 int _fd;
70 } _sigpoll;
71 /* SIGPROF */
72 struct {
73 pid_t _pid; /* which child */
74 uid_t _uid; /* sender's uid */
75 unsigned long _pfm_ovfl_counters[4]; /* which PMU counter overflowed */
76 } _sigprof;
77 } _sifields;
78 } siginfo_t;
79
80 /*
81 * How these fields are to be accessed.
82 */
83 #define si_pid _sifields._kill._pid
84 #define si_uid _sifields._kill._uid
85 #define si_status _sifields._sigchld._status
86 #define si_utime _sifields._sigchld._utime
87 #define si_stime _sifields._sigchld._stime
88 #define si_value _sifields._rt._sigval
89 #define si_int _sifields._rt._sigval.sival_int
90 #define si_ptr _sifields._rt._sigval.sival_ptr
91 #define si_addr _sifields._sigfault._addr
92 #define si_imm _sifields._sigfault._imm /* as per UNIX SysV ABI spec */
93 #define si_flags _sifields._sigfault._flags
94 /*
95 * si_isr is valid for SIGILL, SIGFPE, SIGSEGV, SIGBUS, and SIGTRAP provided that
96 * si_code is non-zero and __ISR_VALID is set in si_flags.
97 */
98 #define si_isr _sifields._sigfault._isr
99 #define si_band _sifields._sigpoll._band
100 #define si_fd _sifields._sigpoll._fd
101 #define si_pfm_ovfl _sifields._sigprof._pfm_ovfl_counters
102
103 /*
104 * Flag values for si_flags:
105 */
106 #define __ISR_VALID_BIT 0
107 #define __ISR_VALID (1 << __ISR_VALID_BIT)
108
109 /*
110 * si_code values
111 * Positive values for kernel-generated signals.
112 */
113 #ifdef __KERNEL__
114 #define __SI_MASK 0xffff0000
115 #define __SI_KILL (0 << 16)
116 #define __SI_TIMER (1 << 16)
117 #define __SI_POLL (2 << 16)
118 #define __SI_FAULT (3 << 16)
119 #define __SI_CHLD (4 << 16)
120 #define __SI_RT (5 << 16)
121 #define __SI_PROF (6 << 16)
122 #define __SI_CODE(T,N) ((T) << 16 | ((N) & 0xffff))
123 #else
124 #define __SI_KILL 0
125 #define __SI_TIMER 0
126 #define __SI_POLL 0
127 #define __SI_FAULT 0
128 #define __SI_CHLD 0
129 #define __SI_RT 0
130 #define __SI_CODE(T,N) (N)
131 #endif
132
133 #define SI_USER 0 /* sent by kill, sigsend, raise */
134 #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
135 #define SI_QUEUE (-1) /* sent by sigqueue */
136 #define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
137 #define SI_MESGQ (-3) /* sent by real time mesq state change */
138 #define SI_ASYNCIO (-4) /* sent by AIO completion */
139 #define SI_SIGIO (-5) /* sent by queued SIGIO */
140 #define SI_TKILL (-6) /* sent by tkill system call */
141
142 #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
143 #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
144
145 /*
146 * SIGILL si_codes
147 */
148 #define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */
149 #define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */
150 #define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */
151 #define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */
152 #define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */
153 #define ILL_PRVREG (__SI_FAULT|6) /* privileged register */
154 #define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */
155 #define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */
156 #define ILL_BADIADDR (__SI_FAULT|9) /* unimplemented instruction address */
157 #define __ILL_BREAK (__SI_FAULT|10) /* illegal break */
158 #define __ILL_BNDMOD (__SI_FAULT|11) /* bundle-update (modification) in progress */
159 #define NSIGILL 11
160
161 /*
162 * SIGFPE si_codes
163 */
164 #define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */
165 #define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */
166 #define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */
167 #define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */
168 #define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */
169 #define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */
170 #define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */
171 #define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */
172 #define __FPE_DECOVF (__SI_FAULT|9) /* decimal overflow */
173 #define __FPE_DECDIV (__SI_FAULT|10) /* decimal division by zero */
174 #define __FPE_DECERR (__SI_FAULT|11) /* packed decimal error */
175 #define __FPE_INVASC (__SI_FAULT|12) /* invalid ASCII digit */
176 #define __FPE_INVDEC (__SI_FAULT|13) /* invalid decimal digit */
177 #define NSIGFPE 13
178
179 /*
180 * SIGSEGV si_codes
181 */
182 #define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */
183 #define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */
184 #define __SEGV_PSTKOVF (__SI_FAULT|3) /* paragraph stack overflow */
185 #define NSIGSEGV 3
186
187 /*
188 * SIGBUS si_codes
189 */
190 #define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */
191 #define BUS_ADRERR (__SI_FAULT|2) /* non-existant physical address */
192 #define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */
193 #define NSIGBUS 3
194
195 /*
196 * SIGTRAP si_codes
197 */
198 #define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */
199 #define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */
200 #define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */
201 #define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint or watchpoint */
202 #define NSIGTRAP 4
203
204 /*
205 * SIGCHLD si_codes
206 */
207 #define CLD_EXITED (__SI_CHLD|1) /* child has exited */
208 #define CLD_KILLED (__SI_CHLD|2) /* child was killed */
209 #define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */
210 #define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */
211 #define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */
212 #define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */
213 #define NSIGCHLD 6
214
215 /*
216 * SIGPOLL si_codes
217 */
218 #define POLL_IN (__SI_POLL|1) /* data input available */
219 #define POLL_OUT (__SI_POLL|2) /* output buffers available */
220 #define POLL_MSG (__SI_POLL|3) /* input message available */
221 #define POLL_ERR (__SI_POLL|4) /* i/o error */
222 #define POLL_PRI (__SI_POLL|5) /* high priority input available */
223 #define POLL_HUP (__SI_POLL|6) /* device disconnected */
224 #define NSIGPOLL 6
225
226 /*
227 * SIGPROF si_codes
228 */
229 #define PROF_OVFL (__SI_PROF|1) /* some counters overflowed */
230
231 /*
232 * sigevent definitions
233 *
234 * It seems likely that SIGEV_THREAD will have to be handled from userspace, libpthread
235 * transmuting it to SIGEV_SIGNAL, which the thread manager then catches and does the
236 * appropriate nonsense. However, everything is written out here so as to not get lost.
237 */
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
242 #define SIGEV_MAX_SIZE 64
243 #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 4)
244
245 typedef struct sigevent {
246 sigval_t sigev_value;
247 int sigev_signo;
248 int sigev_notify;
249 union {
250 int _pad[SIGEV_PAD_SIZE];
251
252 struct {
253 void (*_function)(sigval_t);
254 void *_attribute; /* really pthread_attr_t */
255 } _sigev_thread;
256 } _sigev_un;
257 } sigevent_t;
258
259 #define sigev_notify_function _sigev_un._sigev_thread._function
260 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
261
262 #ifdef __KERNEL__
263 #include <linux/string.h>
264
265 static inline void
copy_siginfo(siginfo_t * to,siginfo_t * from)266 copy_siginfo (siginfo_t *to, siginfo_t *from)
267 {
268 if (from->si_code < 0)
269 memcpy(to, from, sizeof(siginfo_t));
270 else
271 /* _sigprof is currently the largest know union member */
272 memcpy(to, from, 4*sizeof(int) + sizeof(from->_sifields._sigprof));
273 }
274
275 extern int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from);
276 extern int copy_siginfo_from_user(siginfo_t *to, siginfo_t *from);
277
278 #endif /* __KERNEL__ */
279
280 #endif /* _ASM_IA64_SIGINFO_H */
281