Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

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