siginfo.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #if !defined _SIGNAL_H && !defined __need_siginfo_t \
  18. && !defined __need_sigevent_t
  19. # error "Never include this file directly. Use <signal.h> instead"
  20. #endif
  21. #include <bits/wordsize.h>
  22. #if (!defined __have_sigval_t \
  23. && (defined _SIGNAL_H || defined __need_siginfo_t \
  24. || defined __need_sigevent_t))
  25. # define __have_sigval_t 1
  26. /* Type for data associated with a signal. */
  27. typedef union sigval
  28. {
  29. int sival_int;
  30. void *sival_ptr;
  31. } sigval_t;
  32. #endif
  33. #if (!defined __have_siginfo_t \
  34. && (defined _SIGNAL_H || defined __need_siginfo_t))
  35. # define __have_siginfo_t 1
  36. # define __SI_MAX_SIZE 128
  37. # if __WORDSIZE == 64
  38. # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4)
  39. # else
  40. # define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3)
  41. # endif
  42. typedef struct siginfo
  43. {
  44. int si_signo; /* Signal number. */
  45. int si_code; /* Signal code. */
  46. int si_errno; /* If non-zero, an errno value associated with
  47. this signal, as defined in <errno.h>. */
  48. int __pad0[__SI_MAX_SIZE / sizeof (int) - __SI_PAD_SIZE - 3];
  49. /* Explicit padding. */
  50. union
  51. {
  52. int _pad[__SI_PAD_SIZE];
  53. /* kill(). */
  54. struct
  55. {
  56. __pid_t si_pid; /* Sending process ID. */
  57. __uid_t si_uid; /* Real user ID of sending process. */
  58. } _kill;
  59. /* SIGCHLD. */
  60. struct
  61. {
  62. __pid_t si_pid; /* Which child. */
  63. __uid_t si_uid; /* Real user ID of sending process. */
  64. int si_status; /* Exit value or signal. */
  65. __clock_t si_utime;
  66. __clock_t si_stime;
  67. } _sigchld;
  68. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */
  69. struct
  70. {
  71. void *si_addr; /* Faulting insn/memory ref. */
  72. } _sigfault;
  73. /* SIGPOLL. */
  74. struct
  75. {
  76. int si_band; /* Band event for SIGPOLL. */
  77. int si_fd;
  78. } _sigpoll;
  79. /* POSIX.1b timers. */
  80. struct
  81. {
  82. unsigned int _timer1;
  83. unsigned int _timer2;
  84. } _timer;
  85. /* POSIX.1b signals. */
  86. struct
  87. {
  88. __pid_t si_pid; /* Sending process ID. */
  89. __uid_t si_uid; /* Real user ID of sending process. */
  90. sigval_t si_sigval; /* Signal value. */
  91. } _rt;
  92. } _sifields;
  93. } siginfo_t;
  94. /* X/Open requires some more fields with fixed names. */
  95. # define si_pid _sifields._kill.si_pid
  96. # define si_uid _sifields._kill.si_uid
  97. # define si_status _sifields._sigchld.si_status
  98. # define si_utime _sifields._sigchld.si_utime
  99. # define si_stime _sifields._sigchld.si_stime
  100. # define si_value _sifields._rt.si_sigval
  101. # define si_int _sifields._rt.si_sigval.sival_int
  102. # define si_ptr _sifields._rt.si_sigval.sival_ptr
  103. # define si_addr _sifields._sigfault.si_addr
  104. # define si_band _sifields._sigpoll.si_band
  105. # define si_fd _sifields._sigpoll.si_fd
  106. /* Values for `si_code'. Positive values are reserved for kernel-generated
  107. signals. */
  108. enum
  109. {
  110. SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */
  111. # define SI_ASYNCNL SI_ASYNCNL
  112. SI_TKILL = -6, /* Sent by tkill. */
  113. # define SI_TKILL SI_TKILL
  114. SI_SIGIO, /* Sent by queued SIGIO. */
  115. # define SI_SIGIO SI_SIGIO
  116. SI_MESGQ, /* Sent by real time mesq state change. */
  117. # define SI_MESGQ SI_MESGQ
  118. SI_TIMER, /* Sent by real time mesq state change. */
  119. # define SI_TIMER SI_TIMER
  120. SI_ASYNCIO, /* Sent by AIO completion. */
  121. # define SI_ASYNCIO SI_ASYNCIO
  122. SI_QUEUE, /* Sent by sigqueue. */
  123. # define SI_QUEUE SI_QUEUE
  124. SI_USER, /* Sent by kill, sigsend, raise. */
  125. # define SI_USER SI_USER
  126. SI_KERNEL = 0x80 /* Send by kernel. */
  127. #define SI_KERNEL SI_KERNEL
  128. };
  129. /* `si_code' values for SIGILL signal. */
  130. enum
  131. {
  132. ILL_ILLOPC = 1, /* Illegal opcode. */
  133. # define ILL_ILLOPC ILL_ILLOPC
  134. ILL_ILLOPN, /* Illegal operand. */
  135. # define ILL_ILLOPN ILL_ILLOPN
  136. ILL_ILLADR, /* Illegal addressing mode. */
  137. # define ILL_ILLADR ILL_ILLADR
  138. ILL_ILLTRP, /* Illegal trap. */
  139. # define ILL_ILLTRP ILL_ILLTRP
  140. ILL_PRVOPC, /* Privileged opcode. */
  141. # define ILL_PRVOPC ILL_PRVOPC
  142. ILL_PRVREG, /* Privileged register. */
  143. # define ILL_PRVREG ILL_PRVREG
  144. ILL_COPROC, /* Coprocessor error. */
  145. # define ILL_COPROC ILL_COPROC
  146. ILL_BADSTK /* Internal stack error. */
  147. # define ILL_BADSTK ILL_BADSTK
  148. };
  149. /* `si_code' values for SIGFPE signal. */
  150. enum
  151. {
  152. FPE_INTDIV = 1, /* Integer divide by zero. */
  153. # define FPE_INTDIV FPE_INTDIV
  154. FPE_INTOVF, /* Integer overflow. */
  155. # define FPE_INTOVF FPE_INTOVF
  156. FPE_FLTDIV, /* Floating point divide by zero. */
  157. # define FPE_FLTDIV FPE_FLTDIV
  158. FPE_FLTOVF, /* Floating point overflow. */
  159. # define FPE_FLTOVF FPE_FLTOVF
  160. FPE_FLTUND, /* Floating point underflow. */
  161. # define FPE_FLTUND FPE_FLTUND
  162. FPE_FLTRES, /* Floating point inexact result. */
  163. # define FPE_FLTRES FPE_FLTRES
  164. FPE_FLTINV, /* Floating point invalid operation. */
  165. # define FPE_FLTINV FPE_FLTINV
  166. FPE_FLTSUB /* Subscript out of range. */
  167. # define FPE_FLTSUB FPE_FLTSUB
  168. };
  169. /* `si_code' values for SIGSEGV signal. */
  170. enum
  171. {
  172. SEGV_MAPERR = 1, /* Address not mapped to object. */
  173. # define SEGV_MAPERR SEGV_MAPERR
  174. SEGV_ACCERR /* Invalid permissions for mapped object. */
  175. # define SEGV_ACCERR SEGV_ACCERR
  176. };
  177. /* `si_code' values for SIGBUS signal. */
  178. enum
  179. {
  180. BUS_ADRALN = 1, /* Invalid address alignment. */
  181. # define BUS_ADRALN BUS_ADRALN
  182. BUS_ADRERR, /* Non-existant physical address. */
  183. # define BUS_ADRERR BUS_ADRERR
  184. BUS_OBJERR /* Object specific hardware error. */
  185. # define BUS_OBJERR BUS_OBJERR
  186. };
  187. /* `si_code' values for SIGTRAP signal. */
  188. enum
  189. {
  190. TRAP_BRKPT = 1, /* Process breakpoint. */
  191. # define TRAP_BRKPT TRAP_BRKPT
  192. TRAP_TRACE /* Process trace trap. */
  193. # define TRAP_TRACE TRAP_TRACE
  194. };
  195. /* `si_code' values for SIGCHLD signal. */
  196. enum
  197. {
  198. CLD_EXITED = 1, /* Child has exited. */
  199. # define CLD_EXITED CLD_EXITED
  200. CLD_KILLED, /* Child was killed. */
  201. # define CLD_KILLED CLD_KILLED
  202. CLD_DUMPED, /* Child terminated abnormally. */
  203. # define CLD_DUMPED CLD_DUMPED
  204. CLD_TRAPPED, /* Traced child has trapped. */
  205. # define CLD_TRAPPED CLD_TRAPPED
  206. CLD_STOPPED, /* Child has stopped. */
  207. # define CLD_STOPPED CLD_STOPPED
  208. CLD_CONTINUED /* Stopped child has continued. */
  209. # define CLD_CONTINUED CLD_CONTINUED
  210. };
  211. /* `si_code' values for SIGPOLL signal. */
  212. enum
  213. {
  214. POLL_IN = 1, /* Data input available. */
  215. # define POLL_IN POLL_IN
  216. POLL_OUT, /* Output buffers available. */
  217. # define POLL_OUT POLL_OUT
  218. POLL_MSG, /* Input message available. */
  219. # define POLL_MSG POLL_MSG
  220. POLL_ERR, /* I/O error. */
  221. # define POLL_ERR POLL_ERR
  222. POLL_PRI, /* High priority input available. */
  223. # define POLL_PRI POLL_PRI
  224. POLL_HUP /* Device disconnected. */
  225. # define POLL_HUP POLL_HUP
  226. };
  227. # undef __need_siginfo_t
  228. #endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */
  229. #if (defined _SIGNAL_H || defined __need_sigevent_t) \
  230. && !defined __have_sigevent_t
  231. # define __have_sigevent_t 1
  232. /* Structure to transport application-defined values with signals. */
  233. # define __SIGEV_MAX_SIZE 64
  234. # define __SIGEV_HEAD_SIZE (sizeof(long) + 2*sizeof(int))
  235. # define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE - __SIGEV_HEAD_SIZE) / sizeof (int))
  236. /* Forward declaration of the `pthread_attr_t' type. */
  237. struct __pthread_attr_s;
  238. /* XXX This one might need to change!!! */
  239. typedef struct sigevent
  240. {
  241. sigval_t sigev_value;
  242. int sigev_signo;
  243. int sigev_notify;
  244. union
  245. {
  246. int _pad[__SIGEV_PAD_SIZE];
  247. struct
  248. {
  249. void (*_function) (sigval_t); /* Function to start. */
  250. void *_attribute; /* Really pthread_attr_t. */
  251. } _sigev_thread;
  252. } _sigev_un;
  253. } sigevent_t;
  254. /* POSIX names to access some of the members. */
  255. # define sigev_notify_function _sigev_un._sigev_thread._function
  256. # define sigev_notify_attributes _sigev_un._sigev_thread._attribute
  257. /* `sigev_notify' values. */
  258. enum
  259. {
  260. SIGEV_SIGNAL = 0, /* Notify via signal. */
  261. # define SIGEV_SIGNAL SIGEV_SIGNAL
  262. SIGEV_NONE, /* Other notification: meaningless. */
  263. # define SIGEV_NONE SIGEV_NONE
  264. SIGEV_THREAD, /* Deliver via thread creation. */
  265. # define SIGEV_THREAD SIGEV_THREAD
  266. SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */
  267. #define SIGEV_THREAD_ID SIGEV_THREAD_ID
  268. };
  269. #endif /* have _SIGNAL_H. */