signal.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 SEGV_MTEAERR 8
  63. #define SEGV_MTESERR 9
  64. #define BUS_ADRALN 1
  65. #define BUS_ADRERR 2
  66. #define BUS_OBJERR 3
  67. #define BUS_MCEERR_AR 4
  68. #define BUS_MCEERR_AO 5
  69. #define CLD_EXITED 1
  70. #define CLD_KILLED 2
  71. #define CLD_DUMPED 3
  72. #define CLD_TRAPPED 4
  73. #define CLD_STOPPED 5
  74. #define CLD_CONTINUED 6
  75. union sigval {
  76. int sival_int;
  77. void *sival_ptr;
  78. };
  79. typedef struct {
  80. #ifdef __SI_SWAP_ERRNO_CODE
  81. int si_signo, si_code, si_errno;
  82. #else
  83. int si_signo, si_errno, si_code;
  84. #endif
  85. union {
  86. char __pad[128 - 2*sizeof(int) - sizeof(long)];
  87. struct {
  88. union {
  89. struct {
  90. pid_t si_pid;
  91. uid_t si_uid;
  92. } __piduid;
  93. struct {
  94. int si_timerid;
  95. int si_overrun;
  96. } __timer;
  97. } __first;
  98. union {
  99. union sigval si_value;
  100. struct {
  101. int si_status;
  102. clock_t si_utime, si_stime;
  103. } __sigchld;
  104. } __second;
  105. } __si_common;
  106. struct {
  107. void *si_addr;
  108. short si_addr_lsb;
  109. union {
  110. struct {
  111. void *si_lower;
  112. void *si_upper;
  113. } __addr_bnd;
  114. unsigned si_pkey;
  115. } __first;
  116. } __sigfault;
  117. struct {
  118. long si_band;
  119. int si_fd;
  120. } __sigpoll;
  121. struct {
  122. void *si_call_addr;
  123. int si_syscall;
  124. unsigned si_arch;
  125. } __sigsys;
  126. } __si_fields;
  127. } siginfo_t;
  128. #define si_pid __si_fields.__si_common.__first.__piduid.si_pid
  129. #define si_uid __si_fields.__si_common.__first.__piduid.si_uid
  130. #define si_status __si_fields.__si_common.__second.__sigchld.si_status
  131. #define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
  132. #define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
  133. #define si_value __si_fields.__si_common.__second.si_value
  134. #define si_addr __si_fields.__sigfault.si_addr
  135. #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
  136. #define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
  137. #define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
  138. #define si_pkey __si_fields.__sigfault.__first.si_pkey
  139. #define si_band __si_fields.__sigpoll.si_band
  140. #define si_fd __si_fields.__sigpoll.si_fd
  141. #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
  142. #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
  143. #define si_ptr si_value.sival_ptr
  144. #define si_int si_value.sival_int
  145. #define si_call_addr __si_fields.__sigsys.si_call_addr
  146. #define si_syscall __si_fields.__sigsys.si_syscall
  147. #define si_arch __si_fields.__sigsys.si_arch
  148. struct sigaction {
  149. union {
  150. void (*sa_handler)(int);
  151. void (*sa_sigaction)(int, siginfo_t *, void *);
  152. } __sa_handler;
  153. sigset_t sa_mask;
  154. int sa_flags;
  155. void (*sa_restorer)(void);
  156. };
  157. #define sa_handler __sa_handler.sa_handler
  158. #define sa_sigaction __sa_handler.sa_sigaction
  159. #define SA_UNSUPPORTED 0x00000400
  160. #define SA_EXPOSE_TAGBITS 0x00000800
  161. struct sigevent {
  162. union sigval sigev_value;
  163. int sigev_signo;
  164. int sigev_notify;
  165. union {
  166. char __pad[64 - 2*sizeof(int) - sizeof(union sigval)];
  167. pid_t sigev_notify_thread_id;
  168. struct {
  169. void (*sigev_notify_function)(union sigval);
  170. pthread_attr_t *sigev_notify_attributes;
  171. } __sev_thread;
  172. } __sev_fields;
  173. };
  174. #define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
  175. #define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function
  176. #define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes
  177. #define SIGEV_SIGNAL 0
  178. #define SIGEV_NONE 1
  179. #define SIGEV_THREAD 2
  180. #define SIGEV_THREAD_ID 4
  181. int __libc_current_sigrtmin(void);
  182. int __libc_current_sigrtmax(void);
  183. #define SIGRTMIN (__libc_current_sigrtmin())
  184. #define SIGRTMAX (__libc_current_sigrtmax())
  185. int kill(pid_t, int);
  186. int sigemptyset(sigset_t *);
  187. int sigfillset(sigset_t *);
  188. int sigaddset(sigset_t *, int);
  189. int sigdelset(sigset_t *, int);
  190. int sigismember(const sigset_t *, int);
  191. int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
  192. int sigsuspend(const sigset_t *);
  193. int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
  194. int sigpending(sigset_t *);
  195. int sigwait(const sigset_t *__restrict, int *__restrict);
  196. int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
  197. int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
  198. int sigqueue(pid_t, int, union sigval);
  199. int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
  200. int pthread_kill(pthread_t, int);
  201. void psiginfo(const siginfo_t *, const char *);
  202. void psignal(int, const char *);
  203. #endif
  204. #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  205. int killpg(pid_t, int);
  206. int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
  207. int sighold(int);
  208. int sigignore(int);
  209. int siginterrupt(int, int);
  210. int sigpause(int);
  211. int sigrelse(int);
  212. void (*sigset(int, void (*)(int)))(int);
  213. #define TRAP_BRKPT 1
  214. #define TRAP_TRACE 2
  215. #define TRAP_BRANCH 3
  216. #define TRAP_HWBKPT 4
  217. #define TRAP_UNK 5
  218. #define POLL_IN 1
  219. #define POLL_OUT 2
  220. #define POLL_MSG 3
  221. #define POLL_ERR 4
  222. #define POLL_PRI 5
  223. #define POLL_HUP 6
  224. #define SS_ONSTACK 1
  225. #define SS_DISABLE 2
  226. #define SS_AUTODISARM (1U << 31)
  227. #define SS_FLAG_BITS SS_AUTODISARM
  228. #endif
  229. #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
  230. #define NSIG _NSIG
  231. typedef void (*sig_t)(int);
  232. #define SYS_SECCOMP 1
  233. #define SYS_USER_DISPATCH 2
  234. #endif
  235. #ifdef _GNU_SOURCE
  236. typedef void (*sighandler_t)(int);
  237. void (*bsd_signal(int, void (*)(int)))(int);
  238. int sigisemptyset(const sigset_t *);
  239. int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
  240. int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
  241. #define SA_NOMASK SA_NODEFER
  242. #define SA_ONESHOT SA_RESETHAND
  243. #endif
  244. #define SIG_ERR ((void (*)(int))-1)
  245. #define SIG_DFL ((void (*)(int)) 0)
  246. #define SIG_IGN ((void (*)(int)) 1)
  247. typedef int sig_atomic_t;
  248. void (*signal(int, void (*)(int)))(int);
  249. int raise(int);
  250. #if _REDIR_TIME64
  251. #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  252. || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  253. || defined(_BSD_SOURCE)
  254. __REDIR(sigtimedwait, __sigtimedwait_time64);
  255. #endif
  256. #endif
  257. #ifdef __cplusplus
  258. }
  259. #endif
  260. #endif