siginfo.h 8.7 KB

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