siginfo.h 7.9 KB

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