siginfo.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /* siginfo_t, sigevent and constants. Linux x86-64 version.
  2. Copyright (C) 2012-2016 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #if !defined _SIGNAL_H && !defined __need_siginfo_t \
  16. && !defined __need_sigevent_t
  17. # error "Never include this file directly. Use <signal.h> instead"
  18. #endif
  19. #include <bits/wordsize.h>
  20. #if (!defined __have_sigval_t \
  21. && (defined _SIGNAL_H || defined __need_siginfo_t \
  22. || defined __need_sigevent_t))
  23. # define __have_sigval_t 1
  24. /* Type for data associated with a signal. */
  25. typedef union sigval
  26. {
  27. int sival_int;
  28. void *sival_ptr;
  29. } sigval_t;
  30. #endif
  31. #if (!defined __have_siginfo_t \
  32. && (defined _SIGNAL_H || defined __need_siginfo_t))
  33. # define __have_siginfo_t 1
  34. # define __SI_MAX_SIZE 128
  35. # if __WORDSIZE == 64
  36. # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4)
  37. # else
  38. # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
  39. # endif
  40. # if defined __x86_64__ && __WORDSIZE == 32
  41. /* si_utime and si_stime must be 4 byte aligned for x32 to match the
  42. kernel. We align siginfo_t to 8 bytes so that si_utime and si_stime
  43. are actually aligned to 8 bytes since their offsets are multiple of
  44. 8 bytes. */
  45. typedef __clock_t __attribute__ ((__aligned__ (4))) __sigchld_clock_t;
  46. # define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))
  47. # else
  48. typedef __clock_t __sigchld_clock_t;
  49. # define __SI_ALIGNMENT
  50. # endif
  51. typedef struct
  52. {
  53. int si_signo; /* Signal number. */
  54. int si_errno; /* If non-zero, an errno value associated with
  55. this signal, as defined in <errno.h>. */
  56. int si_code; /* Signal code. */
  57. union
  58. {
  59. int _pad[__SI_PAD_SIZE];
  60. /* kill(). */
  61. struct
  62. {
  63. __pid_t si_pid; /* Sending process ID. */
  64. __uid_t si_uid; /* Real user ID of sending process. */
  65. } _kill;
  66. /* POSIX.1b timers. */
  67. struct
  68. {
  69. int si_tid; /* Timer ID. */
  70. int si_overrun; /* Overrun count. */
  71. sigval_t si_sigval; /* Signal value. */
  72. } _timer;
  73. /* POSIX.1b signals. */
  74. struct
  75. {
  76. __pid_t si_pid; /* Sending process ID. */
  77. __uid_t si_uid; /* Real user ID of sending process. */
  78. sigval_t si_sigval; /* Signal value. */
  79. } _rt;
  80. /* SIGCHLD. */
  81. struct
  82. {
  83. __pid_t si_pid; /* Which child. */
  84. __uid_t si_uid; /* Real user ID of sending process. */
  85. int si_status; /* Exit value or signal. */
  86. __sigchld_clock_t si_utime;
  87. __sigchld_clock_t si_stime;
  88. } _sigchld;
  89. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
  90. struct
  91. {
  92. void *si_addr; /* Faulting insn/memory ref. */
  93. short int si_addr_lsb; /* Valid LSB of the reported address. */
  94. struct
  95. {
  96. void *_lower;
  97. void *_upper;
  98. } si_addr_bnd;
  99. } _sigfault;
  100. /* SIGPOLL. */
  101. struct
  102. {
  103. long int si_band; /* Band event for SIGPOLL. */
  104. int si_fd;
  105. } _sigpoll;
  106. /* SIGSYS. */
  107. struct
  108. {
  109. void *_call_addr; /* Calling user insn. */
  110. int _syscall; /* Triggering system call number. */
  111. unsigned int _arch; /* AUDIT_ARCH_* of syscall. */
  112. } _sigsys;
  113. } _sifields;
  114. } siginfo_t __SI_ALIGNMENT;
  115. /* X/Open requires some more fields with fixed names. */
  116. # define si_pid _sifields._kill.si_pid
  117. # define si_uid _sifields._kill.si_uid
  118. # define si_timerid _sifields._timer.si_tid
  119. # define si_overrun _sifields._timer.si_overrun
  120. # define si_status _sifields._sigchld.si_status
  121. # define si_utime _sifields._sigchld.si_utime
  122. # define si_stime _sifields._sigchld.si_stime
  123. # define si_value _sifields._rt.si_sigval
  124. # define si_int _sifields._rt.si_sigval.sival_int
  125. # define si_ptr _sifields._rt.si_sigval.sival_ptr
  126. # define si_addr _sifields._sigfault.si_addr
  127. # define si_addr_lsb _sifields._sigfault.si_addr_lsb
  128. # define si_lower _sifields._sigfault.si_addr_bnd._lower
  129. # define si_upper _sifields._sigfault.si_addr_bnd._upper
  130. # define si_band _sifields._sigpoll.si_band
  131. # define si_fd _sifields._sigpoll.si_fd
  132. # define si_call_addr _sifields._sigsys._call_addr
  133. # define si_syscall _sifields._sigsys._syscall
  134. # define si_arch _sifields._sigsys._arch
  135. /* Values for `si_code'. Positive values are reserved for kernel-generated
  136. signals. */
  137. enum
  138. {
  139. SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */
  140. # define SI_ASYNCNL SI_ASYNCNL
  141. SI_TKILL = -6, /* Sent by tkill. */
  142. # define SI_TKILL SI_TKILL
  143. SI_SIGIO, /* Sent by queued SIGIO. */
  144. # define SI_SIGIO SI_SIGIO
  145. SI_ASYNCIO, /* Sent by AIO completion. */
  146. # define SI_ASYNCIO SI_ASYNCIO
  147. SI_MESGQ, /* Sent by real time mesq state change. */
  148. # define SI_MESGQ SI_MESGQ
  149. SI_TIMER, /* Sent by timer expiration. */
  150. # define SI_TIMER SI_TIMER
  151. SI_QUEUE, /* Sent by sigqueue. */
  152. # define SI_QUEUE SI_QUEUE
  153. SI_USER, /* Sent by kill, sigsend. */
  154. # define SI_USER SI_USER
  155. SI_KERNEL = 0x80 /* Send by kernel. */
  156. #define SI_KERNEL SI_KERNEL
  157. };
  158. # if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
  159. /* `si_code' values for SIGILL signal. */
  160. enum
  161. {
  162. ILL_ILLOPC = 1, /* Illegal opcode. */
  163. # define ILL_ILLOPC ILL_ILLOPC
  164. ILL_ILLOPN, /* Illegal operand. */
  165. # define ILL_ILLOPN ILL_ILLOPN
  166. ILL_ILLADR, /* Illegal addressing mode. */
  167. # define ILL_ILLADR ILL_ILLADR
  168. ILL_ILLTRP, /* Illegal trap. */
  169. # define ILL_ILLTRP ILL_ILLTRP
  170. ILL_PRVOPC, /* Privileged opcode. */
  171. # define ILL_PRVOPC ILL_PRVOPC
  172. ILL_PRVREG, /* Privileged register. */
  173. # define ILL_PRVREG ILL_PRVREG
  174. ILL_COPROC, /* Coprocessor error. */
  175. # define ILL_COPROC ILL_COPROC
  176. ILL_BADSTK /* Internal stack error. */
  177. # define ILL_BADSTK ILL_BADSTK
  178. };
  179. /* `si_code' values for SIGFPE signal. */
  180. enum
  181. {
  182. FPE_INTDIV = 1, /* Integer divide by zero. */
  183. # define FPE_INTDIV FPE_INTDIV
  184. FPE_INTOVF, /* Integer overflow. */
  185. # define FPE_INTOVF FPE_INTOVF
  186. FPE_FLTDIV, /* Floating point divide by zero. */
  187. # define FPE_FLTDIV FPE_FLTDIV
  188. FPE_FLTOVF, /* Floating point overflow. */
  189. # define FPE_FLTOVF FPE_FLTOVF
  190. FPE_FLTUND, /* Floating point underflow. */
  191. # define FPE_FLTUND FPE_FLTUND
  192. FPE_FLTRES, /* Floating point inexact result. */
  193. # define FPE_FLTRES FPE_FLTRES
  194. FPE_FLTINV, /* Floating point invalid operation. */
  195. # define FPE_FLTINV FPE_FLTINV
  196. FPE_FLTSUB /* Subscript out of range. */
  197. # define FPE_FLTSUB FPE_FLTSUB
  198. };
  199. /* `si_code' values for SIGSEGV signal. */
  200. enum
  201. {
  202. SEGV_MAPERR = 1, /* Address not mapped to object. */
  203. # define SEGV_MAPERR SEGV_MAPERR
  204. SEGV_ACCERR /* Invalid permissions for mapped object. */
  205. # define SEGV_ACCERR SEGV_ACCERR
  206. };
  207. /* `si_code' values for SIGBUS signal. */
  208. enum
  209. {
  210. BUS_ADRALN = 1, /* Invalid address alignment. */
  211. # define BUS_ADRALN BUS_ADRALN
  212. BUS_ADRERR, /* Non-existant physical address. */
  213. # define BUS_ADRERR BUS_ADRERR
  214. BUS_OBJERR, /* Object specific hardware error. */
  215. # define BUS_OBJERR BUS_OBJERR
  216. BUS_MCEERR_AR, /* Hardware memory error: action required. */
  217. # define BUS_MCEERR_AR BUS_MCEERR_AR
  218. BUS_MCEERR_AO /* Hardware memory error: action optional. */
  219. # define BUS_MCEERR_AO BUS_MCEERR_AO
  220. };
  221. # endif
  222. # ifdef __USE_XOPEN_EXTENDED
  223. /* `si_code' values for SIGTRAP signal. */
  224. enum
  225. {
  226. TRAP_BRKPT = 1, /* Process breakpoint. */
  227. # define TRAP_BRKPT TRAP_BRKPT
  228. TRAP_TRACE /* Process trace trap. */
  229. # define TRAP_TRACE TRAP_TRACE
  230. };
  231. # endif
  232. # if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
  233. /* `si_code' values for SIGCHLD signal. */
  234. enum
  235. {
  236. CLD_EXITED = 1, /* Child has exited. */
  237. # define CLD_EXITED CLD_EXITED
  238. CLD_KILLED, /* Child was killed. */
  239. # define CLD_KILLED CLD_KILLED
  240. CLD_DUMPED, /* Child terminated abnormally. */
  241. # define CLD_DUMPED CLD_DUMPED
  242. CLD_TRAPPED, /* Traced child has trapped. */
  243. # define CLD_TRAPPED CLD_TRAPPED
  244. CLD_STOPPED, /* Child has stopped. */
  245. # define CLD_STOPPED CLD_STOPPED
  246. CLD_CONTINUED /* Stopped child has continued. */
  247. # define CLD_CONTINUED CLD_CONTINUED
  248. };
  249. /* `si_code' values for SIGPOLL signal. */
  250. enum
  251. {
  252. POLL_IN = 1, /* Data input available. */
  253. # define POLL_IN POLL_IN
  254. POLL_OUT, /* Output buffers available. */
  255. # define POLL_OUT POLL_OUT
  256. POLL_MSG, /* Input message available. */
  257. # define POLL_MSG POLL_MSG
  258. POLL_ERR, /* I/O error. */
  259. # define POLL_ERR POLL_ERR
  260. POLL_PRI, /* High priority input available. */
  261. # define POLL_PRI POLL_PRI
  262. POLL_HUP /* Device disconnected. */
  263. # define POLL_HUP POLL_HUP
  264. };
  265. # endif
  266. # undef __need_siginfo_t
  267. #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */
  268. #if (defined _SIGNAL_H || defined __need_sigevent_t) \
  269. && !defined __have_sigevent_t
  270. # define __have_sigevent_t 1
  271. /* Structure to transport application-defined values with signals. */
  272. # define __SIGEV_MAX_SIZE 64
  273. # if __WORDSIZE == 64
  274. # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4)
  275. # else
  276. # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3)
  277. # endif
  278. /* Forward declaration. */
  279. # ifndef __have_pthread_attr_t
  280. typedef union pthread_attr_t pthread_attr_t;
  281. # define __have_pthread_attr_t 1
  282. # endif
  283. typedef struct sigevent
  284. {
  285. sigval_t sigev_value;
  286. int sigev_signo;
  287. int sigev_notify;
  288. union
  289. {
  290. int _pad[__SIGEV_PAD_SIZE];
  291. /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the
  292. thread to receive the signal. */
  293. __pid_t _tid;
  294. struct
  295. {
  296. void (*_function) (sigval_t); /* Function to start. */
  297. pthread_attr_t *_attribute; /* Thread attributes. */
  298. } _sigev_thread;
  299. } _sigev_un;
  300. } sigevent_t;
  301. /* POSIX names to access some of the members. */
  302. # define sigev_notify_function _sigev_un._sigev_thread._function
  303. # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
  304. /* `sigev_notify' values. */
  305. enum
  306. {
  307. SIGEV_SIGNAL = 0, /* Notify via signal. */
  308. # define SIGEV_SIGNAL SIGEV_SIGNAL
  309. SIGEV_NONE, /* Other notification: meaningless. */
  310. # define SIGEV_NONE SIGEV_NONE
  311. SIGEV_THREAD, /* Deliver via thread creation. */
  312. # define SIGEV_THREAD SIGEV_THREAD
  313. SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */
  314. #define SIGEV_THREAD_ID SIGEV_THREAD_ID
  315. };
  316. #endif /* have _SIGNAL_H. */