GNU Linux-libre 4.14.290-gnu1
[releases.git] / include / uapi / asm-generic / siginfo.h
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_ASM_GENERIC_SIGINFO_H
3 #define _UAPI_ASM_GENERIC_SIGINFO_H
4
5 #include <linux/compiler.h>
6 #include <linux/types.h>
7
8 typedef union sigval {
9         int sival_int;
10         void __user *sival_ptr;
11 } sigval_t;
12
13 /*
14  * This is the size (including padding) of the part of the
15  * struct siginfo that is before the union.
16  */
17 #ifndef __ARCH_SI_PREAMBLE_SIZE
18 #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
19 #endif
20
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
25
26 #ifndef __ARCH_SI_UID_T
27 #define __ARCH_SI_UID_T __kernel_uid32_t
28 #endif
29
30 /*
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.
34  */
35 #ifndef __ARCH_SI_BAND_T
36 #define __ARCH_SI_BAND_T long
37 #endif
38
39 #ifndef __ARCH_SI_CLOCK_T
40 #define __ARCH_SI_CLOCK_T __kernel_clock_t
41 #endif
42
43 #ifndef __ARCH_SI_ATTRIBUTES
44 #define __ARCH_SI_ATTRIBUTES
45 #endif
46
47 #ifndef HAVE_ARCH_SIGINFO_T
48
49 typedef struct siginfo {
50         int si_signo;
51         int si_errno;
52         int si_code;
53
54         union {
55                 int _pad[SI_PAD_SIZE];
56
57                 /* kill() */
58                 struct {
59                         __kernel_pid_t _pid;    /* sender's pid */
60                         __ARCH_SI_UID_T _uid;   /* sender's uid */
61                 } _kill;
62
63                 /* POSIX.1b timers */
64                 struct {
65                         __kernel_timer_t _tid;  /* timer id */
66                         int _overrun;           /* overrun count */
67                         char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
68                         sigval_t _sigval;       /* same as below */
69                         int _sys_private;       /* not to be passed to user */
70                 } _timer;
71
72                 /* POSIX.1b signals */
73                 struct {
74                         __kernel_pid_t _pid;    /* sender's pid */
75                         __ARCH_SI_UID_T _uid;   /* sender's uid */
76                         sigval_t _sigval;
77                 } _rt;
78
79                 /* SIGCHLD */
80                 struct {
81                         __kernel_pid_t _pid;    /* which child */
82                         __ARCH_SI_UID_T _uid;   /* sender's uid */
83                         int _status;            /* exit code */
84                         __ARCH_SI_CLOCK_T _utime;
85                         __ARCH_SI_CLOCK_T _stime;
86                 } _sigchld;
87
88                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
89                 struct {
90                         void __user *_addr; /* faulting insn/memory ref. */
91 #ifdef __ARCH_SI_TRAPNO
92                         int _trapno;    /* TRAP # which caused the signal */
93 #endif
94                         short _addr_lsb; /* LSB of the reported address */
95                         union {
96                                 /* used when si_code=SEGV_BNDERR */
97                                 struct {
98                                         void __user *_lower;
99                                         void __user *_upper;
100                                 } _addr_bnd;
101                                 /* used when si_code=SEGV_PKUERR */
102                                 __u32 _pkey;
103                         };
104                 } _sigfault;
105
106                 /* SIGPOLL */
107                 struct {
108                         __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
109                         int _fd;
110                 } _sigpoll;
111
112                 /* SIGSYS */
113                 struct {
114                         void __user *_call_addr; /* calling user insn */
115                         int _syscall;   /* triggering system call number */
116                         unsigned int _arch;     /* AUDIT_ARCH_* of syscall */
117                 } _sigsys;
118         } _sifields;
119 } __ARCH_SI_ATTRIBUTES siginfo_t;
120
121 /* If the arch shares siginfo, then it has SIGSYS. */
122 #define __ARCH_SIGSYS
123 #endif
124
125 /*
126  * How these fields are to be accessed.
127  */
128 #define si_pid          _sifields._kill._pid
129 #define si_uid          _sifields._kill._uid
130 #define si_tid          _sifields._timer._tid
131 #define si_overrun      _sifields._timer._overrun
132 #define si_sys_private  _sifields._timer._sys_private
133 #define si_status       _sifields._sigchld._status
134 #define si_utime        _sifields._sigchld._utime
135 #define si_stime        _sifields._sigchld._stime
136 #define si_value        _sifields._rt._sigval
137 #define si_int          _sifields._rt._sigval.sival_int
138 #define si_ptr          _sifields._rt._sigval.sival_ptr
139 #define si_addr         _sifields._sigfault._addr
140 #ifdef __ARCH_SI_TRAPNO
141 #define si_trapno       _sifields._sigfault._trapno
142 #endif
143 #define si_addr_lsb     _sifields._sigfault._addr_lsb
144 #define si_lower        _sifields._sigfault._addr_bnd._lower
145 #define si_upper        _sifields._sigfault._addr_bnd._upper
146 #define si_pkey         _sifields._sigfault._pkey
147 #define si_band         _sifields._sigpoll._band
148 #define si_fd           _sifields._sigpoll._fd
149 #ifdef __ARCH_SIGSYS
150 #define si_call_addr    _sifields._sigsys._call_addr
151 #define si_syscall      _sifields._sigsys._syscall
152 #define si_arch         _sifields._sigsys._arch
153 #endif
154
155 /*
156  * si_code values
157  * Digital reserves positive values for kernel-generated signals.
158  */
159 #define SI_USER         0               /* sent by kill, sigsend, raise */
160 #define SI_KERNEL       0x80            /* sent by the kernel from somewhere */
161 #define SI_QUEUE        -1              /* sent by sigqueue */
162 #define SI_TIMER        -2              /* sent by timer expiration */
163 #define SI_MESGQ        -3              /* sent by real time mesq state change */
164 #define SI_ASYNCIO      -4              /* sent by AIO completion */
165 #define SI_SIGIO        -5              /* sent by queued SIGIO */
166 #define SI_TKILL        -6              /* sent by tkill system call */
167 #define SI_DETHREAD     -7              /* sent by execve() killing subsidiary threads */
168
169 #define SI_FROMUSER(siptr)      ((siptr)->si_code <= 0)
170 #define SI_FROMKERNEL(siptr)    ((siptr)->si_code > 0)
171
172 /*
173  * SIGILL si_codes
174  */
175 #define ILL_ILLOPC      1       /* illegal opcode */
176 #define ILL_ILLOPN      2       /* illegal operand */
177 #define ILL_ILLADR      3       /* illegal addressing mode */
178 #define ILL_ILLTRP      4       /* illegal trap */
179 #define ILL_PRVOPC      5       /* privileged opcode */
180 #define ILL_PRVREG      6       /* privileged register */
181 #define ILL_COPROC      7       /* coprocessor error */
182 #define ILL_BADSTK      8       /* internal stack error */
183 #define NSIGILL         8
184
185 /*
186  * SIGFPE si_codes
187  */
188 #define FPE_INTDIV      1       /* integer divide by zero */
189 #define FPE_INTOVF      2       /* integer overflow */
190 #define FPE_FLTDIV      3       /* floating point divide by zero */
191 #define FPE_FLTOVF      4       /* floating point overflow */
192 #define FPE_FLTUND      5       /* floating point underflow */
193 #define FPE_FLTRES      6       /* floating point inexact result */
194 #define FPE_FLTINV      7       /* floating point invalid operation */
195 #define FPE_FLTSUB      8       /* subscript out of range */
196 #define NSIGFPE         8
197
198 /*
199  * SIGSEGV si_codes
200  */
201 #define SEGV_MAPERR     1       /* address not mapped to object */
202 #define SEGV_ACCERR     2       /* invalid permissions for mapped object */
203 #define SEGV_BNDERR     3       /* failed address bound checks */
204 #define SEGV_PKUERR     4       /* failed protection key checks */
205 #define NSIGSEGV        4
206
207 /*
208  * SIGBUS si_codes
209  */
210 #define BUS_ADRALN      1       /* invalid address alignment */
211 #define BUS_ADRERR      2       /* non-existent physical address */
212 #define BUS_OBJERR      3       /* object specific hardware error */
213 /* hardware memory error consumed on a machine check: action required */
214 #define BUS_MCEERR_AR   4
215 /* hardware memory error detected in process but not consumed: action optional*/
216 #define BUS_MCEERR_AO   5
217 #define NSIGBUS         5
218
219 /*
220  * SIGTRAP si_codes
221  */
222 #define TRAP_BRKPT      1       /* process breakpoint */
223 #define TRAP_TRACE      2       /* process trace trap */
224 #define TRAP_BRANCH     3       /* process taken branch trap */
225 #define TRAP_HWBKPT     4       /* hardware breakpoint/watchpoint */
226 #define NSIGTRAP        4
227
228 /*
229  * SIGCHLD si_codes
230  */
231 #define CLD_EXITED      1       /* child has exited */
232 #define CLD_KILLED      2       /* child was killed */
233 #define CLD_DUMPED      3       /* child terminated abnormally */
234 #define CLD_TRAPPED     4       /* traced child has trapped */
235 #define CLD_STOPPED     5       /* child has stopped */
236 #define CLD_CONTINUED   6       /* stopped child has continued */
237 #define NSIGCHLD        6
238
239 /*
240  * SIGPOLL (or any other signal without signal specific si_codes) si_codes
241  */
242 #define POLL_IN         1       /* data input available */
243 #define POLL_OUT        2       /* output buffers available */
244 #define POLL_MSG        3       /* input message available */
245 #define POLL_ERR        4       /* i/o error */
246 #define POLL_PRI        5       /* high priority input available */
247 #define POLL_HUP        6       /* device disconnected */
248 #define NSIGPOLL        6
249
250 /*
251  * SIGSYS si_codes
252  */
253 #define SYS_SECCOMP     1       /* seccomp triggered */
254 #define NSIGSYS         1
255
256 /*
257  * sigevent definitions
258  * 
259  * It seems likely that SIGEV_THREAD will have to be handled from 
260  * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
261  * thread manager then catches and does the appropriate nonsense.
262  * However, everything is written out here so as to not get lost.
263  */
264 #define SIGEV_SIGNAL    0       /* notify via signal */
265 #define SIGEV_NONE      1       /* other notification: meaningless */
266 #define SIGEV_THREAD    2       /* deliver via thread creation */
267 #define SIGEV_THREAD_ID 4       /* deliver to thread */
268
269 /*
270  * This works because the alignment is ok on all current architectures
271  * but we leave open this being overridden in the future
272  */
273 #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
274 #define __ARCH_SIGEV_PREAMBLE_SIZE      (sizeof(int) * 2 + sizeof(sigval_t))
275 #endif
276
277 #define SIGEV_MAX_SIZE  64
278 #define SIGEV_PAD_SIZE  ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
279                 / sizeof(int))
280
281 typedef struct sigevent {
282         sigval_t sigev_value;
283         int sigev_signo;
284         int sigev_notify;
285         union {
286                 int _pad[SIGEV_PAD_SIZE];
287                  int _tid;
288
289                 struct {
290                         void (*_function)(sigval_t);
291                         void *_attribute;       /* really pthread_attr_t */
292                 } _sigev_thread;
293         } _sigev_un;
294 } sigevent_t;
295
296 #define sigev_notify_function   _sigev_un._sigev_thread._function
297 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
298 #define sigev_notify_thread_id   _sigev_un._tid
299
300
301 #endif /* _UAPI_ASM_GENERIC_SIGINFO_H */