1#ifndef _CRIS_SIGINFO_H
2#define _CRIS_SIGINFO_H
3
4#include <linux/types.h>
5
6/* This is copied from asm-m68k/siginfo.h.  */
7
8typedef union sigval {
9	int sival_int;
10	void *sival_ptr;
11} sigval_t;
12
13#define SI_MAX_SIZE	128
14#define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 3)
15
16typedef struct siginfo {
17	int si_signo;
18	int si_errno;
19	int si_code;
20
21	union {
22		int _pad[SI_PAD_SIZE];
23
24		/* kill() */
25		struct {
26			pid_t _pid;		/* sender's pid */
27			uid_t _uid;		/* sender's uid */
28		} _kill;
29
30		/* POSIX.1b timers */
31		struct {
32			unsigned int _timer1;
33			unsigned int _timer2;
34		} _timer;
35
36		/* POSIX.1b signals */
37		struct {
38			pid_t _pid;		/* sender's pid */
39			uid_t _uid;		/* sender's uid */
40			sigval_t _sigval;
41		} _rt;
42
43		/* SIGCHLD */
44		struct {
45			pid_t _pid;		/* which child */
46			uid_t _uid;		/* sender's uid */
47			int _status;		/* exit code */
48			clock_t _utime;
49			clock_t _stime;
50		} _sigchld;
51
52		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
53		struct {
54			void *_addr; /* faulting insn/memory ref. */
55		} _sigfault;
56
57		/* SIGPOLL */
58		struct {
59			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
60			int _fd;
61		} _sigpoll;
62	} _sifields;
63} siginfo_t;
64
65/*
66 * How these fields are to be accessed.
67 */
68#define si_pid		_sifields._kill._pid
69#define si_uid		_sifields._kill._uid
70#define si_status	_sifields._sigchld._status
71#define si_utime	_sifields._sigchld._utime
72#define si_stime	_sifields._sigchld._stime
73#define si_value	_sifields._rt._sigval
74#define si_int		_sifields._rt._sigval.sival_int
75#define si_ptr		_sifields._rt._sigval.sival_ptr
76#define si_addr		_sifields._sigfault._addr
77#define si_band		_sifields._sigpoll._band
78#define si_fd		_sifields._sigpoll._fd
79
80#ifdef __KERNEL__
81#define __SI_MASK	0xffff0000
82#define __SI_KILL	(0 << 16)
83#define __SI_TIMER	(1 << 16)
84#define __SI_POLL	(2 << 16)
85#define __SI_FAULT	(3 << 16)
86#define __SI_CHLD	(4 << 16)
87#define __SI_RT		(5 << 16)
88#define __SI_CODE(T,N)	((T) << 16 | ((N) & 0xffff))
89#else
90#define __SI_KILL	0
91#define __SI_TIMER	0
92#define __SI_POLL	0
93#define __SI_FAULT	0
94#define __SI_CHLD	0
95#define __SI_RT		0
96#define __SI_CODE(T,N)	(N)
97#endif
98
99/*
100 * si_code values
101 * Digital reserves positive values for kernel-generated signals.
102 */
103#define SI_USER		0		/* sent by kill, sigsend, raise */
104#define SI_KERNEL	0x80		/* sent by the kernel from somewhere */
105#define SI_QUEUE	-1		/* sent by sigqueue */
106#define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */
107#define SI_MESGQ	-3		/* sent by real time mesq state change */
108#define SI_ASYNCIO	-4		/* sent by AIO completion */
109#define SI_SIGIO	-5		/* sent by queued SIGIO */
110#define SI_TKILL	-6		/* sent by tkill system call */
111
112#define SI_FROMUSER(siptr)	((siptr)->si_code <= 0)
113#define SI_FROMKERNEL(siptr)	((siptr)->si_code > 0)
114
115/*
116 * SIGILL si_codes
117 */
118#define ILL_ILLOPC	(__SI_FAULT|1)	/* illegal opcode */
119#define ILL_ILLOPN	(__SI_FAULT|2)	/* illegal operand */
120#define ILL_ILLADR	(__SI_FAULT|3)	/* illegal addressing mode */
121#define ILL_ILLTRP	(__SI_FAULT|4)	/* illegal trap */
122#define ILL_PRVOPC	(__SI_FAULT|5)	/* privileged opcode */
123#define ILL_PRVREG	(__SI_FAULT|6)	/* privileged register */
124#define ILL_COPROC	(__SI_FAULT|7)	/* coprocessor error */
125#define ILL_BADSTK	(__SI_FAULT|8)	/* internal stack error */
126#define NSIGILL		8
127
128/*
129 * SIGFPE si_codes
130 */
131#define FPE_INTDIV	(__SI_FAULT|1)	/* integer divide by zero */
132#define FPE_INTOVF	(__SI_FAULT|2)	/* integer overflow */
133#define FPE_FLTDIV	(__SI_FAULT|3)	/* floating point divide by zero */
134#define FPE_FLTOVF	(__SI_FAULT|4)	/* floating point overflow */
135#define FPE_FLTUND	(__SI_FAULT|5)	/* floating point underflow */
136#define FPE_FLTRES	(__SI_FAULT|6)	/* floating point inexact result */
137#define FPE_FLTINV	(__SI_FAULT|7)	/* floating point invalid operation */
138#define FPE_FLTSUB	(__SI_FAULT|8)	/* subscript out of range */
139#define NSIGFPE		8
140
141/*
142 * SIGSEGV si_codes
143 */
144#define SEGV_MAPERR	(__SI_FAULT|1)	/* address not mapped to object */
145#define SEGV_ACCERR	(__SI_FAULT|2)	/* invalid permissions for mapped object */
146#define NSIGSEGV	2
147
148/*
149 * SIGBUS si_codes
150 */
151#define BUS_ADRALN	(__SI_FAULT|1)	/* invalid address alignment */
152#define BUS_ADRERR	(__SI_FAULT|2)	/* non-existant physical address */
153#define BUS_OBJERR	(__SI_FAULT|3)	/* object specific hardware error */
154#define NSIGBUS		3
155
156/*
157 * SIGTRAP si_codes
158 */
159#define TRAP_BRKPT	(__SI_FAULT|1)	/* process breakpoint */
160#define TRAP_TRACE	(__SI_FAULT|2)	/* process trace trap */
161#define NSIGTRAP	2
162
163/*
164 * SIGCHLD si_codes
165 */
166#define CLD_EXITED	(__SI_CHLD|1)	/* child has exited */
167#define CLD_KILLED	(__SI_CHLD|2)	/* child was killed */
168#define CLD_DUMPED	(__SI_CHLD|3)	/* child terminated abnormally */
169#define CLD_TRAPPED	(__SI_CHLD|4)	/* traced child has trapped */
170#define CLD_STOPPED	(__SI_CHLD|5)	/* child has stopped */
171#define CLD_CONTINUED	(__SI_CHLD|6)	/* stopped child has continued */
172#define NSIGCHLD	6
173
174/*
175 * SIGPOLL si_codes
176 */
177#define POLL_IN		(__SI_POLL|1)	/* data input available */
178#define POLL_OUT	(__SI_POLL|2)	/* output buffers available */
179#define POLL_MSG	(__SI_POLL|3)	/* input message available */
180#define POLL_ERR	(__SI_POLL|4)	/* i/o error */
181#define POLL_PRI	(__SI_POLL|5)	/* high priority input available */
182#define POLL_HUP	(__SI_POLL|6)	/* device disconnected */
183#define NSIGPOLL	6
184
185/*
186 * sigevent definitions
187 *
188 * It seems likely that SIGEV_THREAD will have to be handled from
189 * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
190 * thread manager then catches and does the appropriate nonsense.
191 * However, everything is written out here so as to not get lost.
192 */
193#define SIGEV_SIGNAL	0	/* notify via signal */
194#define SIGEV_NONE	1	/* other notification: meaningless */
195#define SIGEV_THREAD	2	/* deliver via thread creation */
196
197#define SIGEV_MAX_SIZE	64
198#define SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 3)
199
200typedef struct sigevent {
201	sigval_t sigev_value;
202	int sigev_signo;
203	int sigev_notify;
204	union {
205		int _pad[SIGEV_PAD_SIZE];
206
207		struct {
208			void (*_function)(sigval_t);
209			void *_attribute;	/* really pthread_attr_t */
210		} _sigev_thread;
211	} _sigev_un;
212} sigevent_t;
213
214#define sigev_notify_function	_sigev_un._sigev_thread._function
215#define sigev_notify_attributes	_sigev_un._sigev_thread._attribute
216
217#ifdef __KERNEL__
218#include <linux/string.h>
219
220extern inline void copy_siginfo(siginfo_t *to, siginfo_t *from)
221{
222	if (from->si_code < 0)
223		memcpy(to, from, sizeof(siginfo_t));
224	else
225		/* _sigchld is currently the largest know union member */
226		memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
227}
228
229extern int copy_siginfo_to_user(siginfo_t *to, siginfo_t *from);
230
231#endif /* __KERNEL__ */
232
233#endif
234