siginfo.h 8.4 KB

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