signal.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. #ifndef _SIGNAL_H
  2. #define _SIGNAL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  8. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  9. || defined(_BSD_SOURCE)
  10. #ifdef _GNU_SOURCE
  11. #define __ucontext ucontext
  12. #endif
  13. #define __NEED_size_t
  14. #define __NEED_pid_t
  15. #define __NEED_uid_t
  16. #define __NEED_struct_timespec
  17. #define __NEED_pthread_t
  18. #define __NEED_pthread_attr_t
  19. #define __NEED_time_t
  20. #define __NEED_clock_t
  21. #define __NEED_sigset_t
  22. #include <bits/alltypes.h>
  23. #define SIG_BLOCK 0
  24. #define SIG_UNBLOCK 1
  25. #define SIG_SETMASK 2
  26. #define SI_ASYNCNL (-60)
  27. #define SI_TKILL (-6)
  28. #define SI_SIGIO (-5)
  29. #define SI_ASYNCIO (-4)
  30. #define SI_MESGQ (-3)
  31. #define SI_TIMER (-2)
  32. #define SI_QUEUE (-1)
  33. #define SI_USER 0
  34. #define SI_KERNEL 128
  35. typedef struct sigaltstack stack_t;
  36. #endif
  37. #include <bits/signal.h>
  38. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  39. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  40. || defined(_BSD_SOURCE)
  41. #define SIG_HOLD ((void (*)(int)) 2)
  42. #define FPE_INTDIV 1
  43. #define FPE_INTOVF 2
  44. #define FPE_FLTDIV 3
  45. #define FPE_FLTOVF 4
  46. #define FPE_FLTUND 5
  47. #define FPE_FLTRES 6
  48. #define FPE_FLTINV 7
  49. #define FPE_FLTSUB 8
  50. #define ILL_ILLOPC 1
  51. #define ILL_ILLOPN 2
  52. #define ILL_ILLADR 3
  53. #define ILL_ILLTRP 4
  54. #define ILL_PRVOPC 5
  55. #define ILL_PRVREG 6
  56. #define ILL_COPROC 7
  57. #define ILL_BADSTK 8
  58. #define SEGV_MAPERR 1
  59. #define SEGV_ACCERR 2
  60. #define SEGV_BNDERR 3
  61. #define SEGV_PKUERR 4
  62. #define BUS_ADRALN 1
  63. #define BUS_ADRERR 2
  64. #define BUS_OBJERR 3
  65. #define BUS_MCEERR_AR 4
  66. #define BUS_MCEERR_AO 5
  67. #define CLD_EXITED 1
  68. #define CLD_KILLED 2
  69. #define CLD_DUMPED 3
  70. #define CLD_TRAPPED 4
  71. #define CLD_STOPPED 5
  72. #define CLD_CONTINUED 6
  73. union sigval {
  74. int sival_int;
  75. void *sival_ptr;
  76. };
  77. typedef struct {
  78. #ifdef __SI_SWAP_ERRNO_CODE
  79. int si_signo, si_code, si_errno;
  80. #else
  81. int si_signo, si_errno, si_code;
  82. #endif
  83. union {
  84. char __pad[128 - 2*sizeof(int) - sizeof(long)];
  85. struct {
  86. union {
  87. struct {
  88. pid_t si_pid;
  89. uid_t si_uid;
  90. } __piduid;
  91. struct {
  92. int si_timerid;
  93. int si_overrun;
  94. } __timer;
  95. } __first;
  96. union {
  97. union sigval si_value;
  98. struct {
  99. int si_status;
  100. clock_t si_utime, si_stime;
  101. } __sigchld;
  102. } __second;
  103. } __si_common;
  104. struct {
  105. void *si_addr;
  106. short si_addr_lsb;
  107. union {
  108. struct {
  109. void *si_lower;
  110. void *si_upper;
  111. } __addr_bnd;
  112. unsigned si_pkey;
  113. } __first;
  114. } __sigfault;
  115. struct {
  116. long si_band;
  117. int si_fd;
  118. } __sigpoll;
  119. struct {
  120. void *si_call_addr;
  121. int si_syscall;
  122. unsigned si_arch;
  123. } __sigsys;
  124. } __si_fields;
  125. } siginfo_t;
  126. #define si_pid __si_fields.__si_common.__first.__piduid.si_pid
  127. #define si_uid __si_fields.__si_common.__first.__piduid.si_uid
  128. #define si_status __si_fields.__si_common.__second.__sigchld.si_status
  129. #define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
  130. #define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
  131. #define si_value __si_fields.__si_common.__second.si_value
  132. #define si_addr __si_fields.__sigfault.si_addr
  133. #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
  134. #define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
  135. #define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
  136. #define si_pkey __si_fields.__sigfault.__first.si_pkey
  137. #define si_band __si_fields.__sigpoll.si_band
  138. #define si_fd __si_fields.__sigpoll.si_fd
  139. #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
  140. #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
  141. #define si_ptr si_value.sival_ptr
  142. #define si_int si_value.sival_int
  143. #define si_call_addr __si_fields.__sigsys.si_call_addr
  144. #define si_syscall __si_fields.__sigsys.si_syscall
  145. #define si_arch __si_fields.__sigsys.si_arch
  146. struct sigaction {
  147. union {
  148. void (*sa_handler)(int);
  149. void (*sa_sigaction)(int, siginfo_t *, void *);
  150. } __sa_handler;
  151. sigset_t sa_mask;
  152. int sa_flags;
  153. void (*sa_restorer)(void);
  154. };
  155. #define sa_handler __sa_handler.sa_handler
  156. #define sa_sigaction __sa_handler.sa_sigaction
  157. struct sigevent {
  158. union sigval sigev_value;
  159. int sigev_signo;
  160. int sigev_notify;
  161. void (*sigev_notify_function)(union sigval);
  162. pthread_attr_t *sigev_notify_attributes;
  163. char __pad[56-3*sizeof(long)];
  164. };
  165. #define SIGEV_SIGNAL 0
  166. #define SIGEV_NONE 1
  167. #define SIGEV_THREAD 2
  168. int __libc_current_sigrtmin(void);
  169. int __libc_current_sigrtmax(void);
  170. #define SIGRTMIN (__libc_current_sigrtmin())
  171. #define SIGRTMAX (__libc_current_sigrtmax())
  172. int kill(pid_t, int);
  173. int sigemptyset(sigset_t *);
  174. int sigfillset(sigset_t *);
  175. int sigaddset(sigset_t *, int);
  176. int sigdelset(sigset_t *, int);
  177. int sigismember(const sigset_t *, int);
  178. int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
  179. int sigsuspend(const sigset_t *);
  180. int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
  181. int sigpending(sigset_t *);
  182. int sigwait(const sigset_t *__restrict, int *__restrict);
  183. int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
  184. int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
  185. int sigqueue(pid_t, int, const union sigval);
  186. int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
  187. int pthread_kill(pthread_t, int);
  188. void psiginfo(const siginfo_t *, const char *);
  189. void psignal(int, const char *);
  190. #endif
  191. #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  192. int killpg(pid_t, int);
  193. int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
  194. int sighold(int);
  195. int sigignore(int);
  196. int siginterrupt(int, int);
  197. int sigpause(int);
  198. int sigrelse(int);
  199. void (*sigset(int, void (*)(int)))(int);
  200. #define TRAP_BRKPT 1
  201. #define TRAP_TRACE 2
  202. #define POLL_IN 1
  203. #define POLL_OUT 2
  204. #define POLL_MSG 3
  205. #define POLL_ERR 4
  206. #define POLL_PRI 5
  207. #define POLL_HUP 6
  208. #define SS_ONSTACK 1
  209. #define SS_DISABLE 2
  210. #endif
  211. #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  212. #define NSIG _NSIG
  213. typedef void (*sig_t)(int);
  214. #endif
  215. #ifdef _GNU_SOURCE
  216. typedef void (*sighandler_t)(int);
  217. void (*bsd_signal(int, void (*)(int)))(int);
  218. int sigisemptyset(const sigset_t *);
  219. int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
  220. int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
  221. #define SA_NOMASK SA_NODEFER
  222. #define SA_ONESHOT SA_RESETHAND
  223. #endif
  224. #define SIG_ERR ((void (*)(int))-1)
  225. #define SIG_DFL ((void (*)(int)) 0)
  226. #define SIG_IGN ((void (*)(int)) 1)
  227. typedef int sig_atomic_t;
  228. void (*signal(int, void (*)(int)))(int);
  229. int raise(int);
  230. #ifdef __cplusplus
  231. }
  232. #endif
  233. #endif