siginfo.h 8.8 KB

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