siginfo.h 8.7 KB

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