siginfo.h 9.1 KB

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