vserver 1.9.3
[linux-2.6.git] / include / asm-mips / siginfo.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1998, 1999, 2001, 2003 Ralf Baechle
7  * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
8  */
9 #ifndef _ASM_SIGINFO_H
10 #define _ASM_SIGINFO_H
11
12 #include <linux/config.h>
13
14 #define SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int))
15 #define SIGEV_PAD_SIZE  ((SIGEV_MAX_SIZE-SIGEV_HEAD_SIZE) / sizeof(int))
16 #define SI_PAD_SIZE     ((SI_MAX_SIZE/sizeof(int)) - 4)
17
18 #define HAVE_ARCH_SIGINFO_T
19
20 /*
21  * We duplicate the generic versions - <asm-generic/siginfo.h> is just borked
22  * by design ...
23  */
24 #define HAVE_ARCH_COPY_SIGINFO
25 struct siginfo;
26
27 #include <asm-generic/siginfo.h>
28
29 /* This structure matches the 32/n32 ABIs for source compatibility but
30    has Linux extensions.  */
31
32 typedef struct siginfo {
33         int si_signo;
34         int si_code;
35         int si_errno;
36
37         union {
38                 int _pad[SI_PAD_SIZE];
39
40                 /* kill() */
41                 struct {
42                         pid_t _pid;             /* sender's pid */
43                         uid_t _uid;             /* sender's uid */
44                 } _kill;
45
46                 /* SIGCHLD */
47                 struct {
48                         pid_t _pid;             /* which child */
49                         uid_t _uid;             /* sender's uid */
50                         int _status;            /* exit code */
51                         clock_t _utime;
52                         clock_t _stime;
53                 } _sigchld;
54
55                 /* IRIX SIGCHLD */
56                 struct {
57                         pid_t _pid;             /* which child */
58                         clock_t _utime;
59                         int _status;            /* exit code */
60                         clock_t _stime;
61                 } _irix_sigchld;
62
63                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
64                 struct {
65                         void *_addr; /* faulting insn/memory ref. */
66                 } _sigfault;
67
68                 /* SIGPOLL, SIGXFSZ (To do ...)  */
69                 struct {
70 #ifdef CONFIG_MIPS32
71                         int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
72 #endif
73 #ifdef CONFIG_MIPS64
74                         long _band;     /* POLL_IN, POLL_OUT, POLL_MSG */
75 #endif
76                         int _fd;
77                 } _sigpoll;
78
79                 /* POSIX.1b timers */
80                 struct {
81                         timer_t _tid;           /* timer id */
82                         int _overrun;           /* overrun count */
83                         char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
84                         sigval_t _sigval;       /* same as below */
85                         int _sys_private;       /* not to be passed to user */
86                 } _timer;
87
88                 /* POSIX.1b signals */
89                 struct {
90                         pid_t _pid;             /* sender's pid */
91                         uid_t _uid;             /* sender's uid */
92                         sigval_t _sigval;
93                 } _rt;
94
95         } _sifields;
96 } siginfo_t;
97
98 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
99
100 #include <linux/compat.h>
101
102 #define SI_PAD_SIZE32   ((SI_MAX_SIZE/sizeof(int)) - 3)
103
104 typedef union sigval32 {
105         int sival_int;
106         s32 sival_ptr;
107 } sigval_t32;
108
109 typedef struct siginfo32 {
110         int si_signo;
111         int si_code;
112         int si_errno;
113
114         union {
115                 int _pad[SI_PAD_SIZE32];
116
117                 /* kill() */
118                 struct {
119                         compat_pid_t _pid;      /* sender's pid */
120                         compat_uid_t _uid;      /* sender's uid */
121                 } _kill;
122
123                 /* SIGCHLD */
124                 struct {
125                         compat_pid_t _pid;      /* which child */
126                         compat_uid_t _uid;      /* sender's uid */
127                         compat_clock_t _utime;
128                         int _status;            /* exit code */
129                         compat_clock_t _stime;
130                 } _sigchld;
131
132                 /* IRIX SIGCHLD */
133                 struct {
134                         compat_pid_t _pid;      /* which child */
135                         compat_clock_t _utime;
136                         int _status;            /* exit code */
137                         compat_clock_t _stime;
138                 } _irix_sigchld;
139
140                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
141                 struct {
142                         s32 _addr; /* faulting insn/memory ref. */
143                 } _sigfault;
144
145                 /* SIGPOLL, SIGXFSZ (To do ...)  */
146                 struct {
147                         int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
148                         int _fd;
149                 } _sigpoll;
150
151                 /* POSIX.1b timers */
152                 struct {
153                         unsigned int _timer1;
154                         unsigned int _timer2;
155                 } _timer;
156
157                 /* POSIX.1b signals */
158                 struct {
159                         compat_pid_t _pid;      /* sender's pid */
160                         compat_uid_t _uid;      /* sender's uid */
161                         sigval_t32 _sigval;
162                 } _rt;
163
164         } _sifields;
165 } siginfo_t32;
166
167 #endif /* defined(__KERNEL__) && defined(CONFIG_COMPAT) */
168
169 /*
170  * si_code values
171  * Again these have been choosen to be IRIX compatible.
172  */
173 #undef SI_ASYNCIO
174 #undef SI_TIMER
175 #undef SI_MESGQ
176 #define SI_ASYNCIO      -2      /* sent by AIO completion */
177 #define SI_TIMER __SI_CODE(__SI_TIMER,-3) /* sent by timer expiration */
178 #define SI_MESGQ __SI_CODE(__SI_MESGQ,-4) /* sent by real time mesq state change */
179
180 #ifdef __KERNEL__
181
182 /*
183  * Duplicated here because of <asm-generic/siginfo.h> braindamage ...
184  */
185 #include <linux/string.h>
186
187 static inline void copy_siginfo(struct siginfo *to, struct siginfo *from)
188 {
189         if (from->si_code < 0)
190                 memcpy(to, from, sizeof(*to));
191         else
192                 /* _sigchld is currently the largest know union member */
193                 memcpy(to, from, 3*sizeof(int) + sizeof(from->_sifields._sigchld));
194 }
195
196 #endif
197
198 #endif /* _ASM_SIGINFO_H */