siginfo.h 9.9 KB

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