17777dab0Sopenharmony_ci#ifndef _SIGNAL_H
27777dab0Sopenharmony_ci#define _SIGNAL_H
37777dab0Sopenharmony_ci
47777dab0Sopenharmony_ci#ifdef __cplusplus
57777dab0Sopenharmony_ciextern "C" {
67777dab0Sopenharmony_ci#endif
77777dab0Sopenharmony_ci
87777dab0Sopenharmony_ci#include <features.h>
97777dab0Sopenharmony_ci
107777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
117777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
127777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
137777dab0Sopenharmony_ci
147777dab0Sopenharmony_ci#ifdef _GNU_SOURCE
157777dab0Sopenharmony_ci#define __ucontext ucontext
167777dab0Sopenharmony_ci#endif
177777dab0Sopenharmony_ci
187777dab0Sopenharmony_ci#define __NEED_size_t
197777dab0Sopenharmony_ci#define __NEED_pid_t
207777dab0Sopenharmony_ci#define __NEED_uid_t
217777dab0Sopenharmony_ci#define __NEED_struct_timespec
227777dab0Sopenharmony_ci#define __NEED_pthread_t
237777dab0Sopenharmony_ci#define __NEED_pthread_attr_t
247777dab0Sopenharmony_ci#define __NEED_time_t
257777dab0Sopenharmony_ci#define __NEED_clock_t
267777dab0Sopenharmony_ci#define __NEED_sigset_t
277777dab0Sopenharmony_ci
287777dab0Sopenharmony_ci#include <bits/alltypes.h>
297777dab0Sopenharmony_ci
307777dab0Sopenharmony_ci#define SIG_BLOCK     0
317777dab0Sopenharmony_ci#define SIG_UNBLOCK   1
327777dab0Sopenharmony_ci#define SIG_SETMASK   2
337777dab0Sopenharmony_ci
347777dab0Sopenharmony_ci#define SI_ASYNCNL (-60)
357777dab0Sopenharmony_ci#define SI_TKILL (-6)
367777dab0Sopenharmony_ci#define SI_SIGIO (-5)
377777dab0Sopenharmony_ci#define SI_ASYNCIO (-4)
387777dab0Sopenharmony_ci#define SI_MESGQ (-3)
397777dab0Sopenharmony_ci#define SI_TIMER (-2)
407777dab0Sopenharmony_ci#define SI_QUEUE (-1)
417777dab0Sopenharmony_ci#define SI_USER 0
427777dab0Sopenharmony_ci#define SI_KERNEL 128
437777dab0Sopenharmony_ci
447777dab0Sopenharmony_ci
457777dab0Sopenharmony_citypedef struct sigaltstack stack_t;
467777dab0Sopenharmony_ci
477777dab0Sopenharmony_ci#endif
487777dab0Sopenharmony_ci
497777dab0Sopenharmony_ci#include <bits/signal.h>
507777dab0Sopenharmony_ci
517777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
527777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
537777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
547777dab0Sopenharmony_ci
557777dab0Sopenharmony_ci#define SIG_HOLD ((void (*)(int)) 2)
567777dab0Sopenharmony_ci
577777dab0Sopenharmony_ci#define FPE_INTDIV 1
587777dab0Sopenharmony_ci#define FPE_INTOVF 2
597777dab0Sopenharmony_ci#define FPE_FLTDIV 3
607777dab0Sopenharmony_ci#define FPE_FLTOVF 4
617777dab0Sopenharmony_ci#define FPE_FLTUND 5
627777dab0Sopenharmony_ci#define FPE_FLTRES 6
637777dab0Sopenharmony_ci#define FPE_FLTINV 7
647777dab0Sopenharmony_ci#define FPE_FLTSUB 8
657777dab0Sopenharmony_ci
667777dab0Sopenharmony_ci#define ILL_ILLOPC 1
677777dab0Sopenharmony_ci#define ILL_ILLOPN 2
687777dab0Sopenharmony_ci#define ILL_ILLADR 3
697777dab0Sopenharmony_ci#define ILL_ILLTRP 4
707777dab0Sopenharmony_ci#define ILL_PRVOPC 5
717777dab0Sopenharmony_ci#define ILL_PRVREG 6
727777dab0Sopenharmony_ci#define ILL_COPROC 7
737777dab0Sopenharmony_ci#define ILL_BADSTK 8
747777dab0Sopenharmony_ci
757777dab0Sopenharmony_ci#define SEGV_MAPERR 1
767777dab0Sopenharmony_ci#define SEGV_ACCERR 2
777777dab0Sopenharmony_ci#define SEGV_BNDERR 3
787777dab0Sopenharmony_ci#define SEGV_PKUERR 4
797777dab0Sopenharmony_ci
807777dab0Sopenharmony_ci#define BUS_ADRALN 1
817777dab0Sopenharmony_ci#define BUS_ADRERR 2
827777dab0Sopenharmony_ci#define BUS_OBJERR 3
837777dab0Sopenharmony_ci#define BUS_MCEERR_AR 4
847777dab0Sopenharmony_ci#define BUS_MCEERR_AO 5
857777dab0Sopenharmony_ci
867777dab0Sopenharmony_ci#define CLD_EXITED 1
877777dab0Sopenharmony_ci#define CLD_KILLED 2
887777dab0Sopenharmony_ci#define CLD_DUMPED 3
897777dab0Sopenharmony_ci#define CLD_TRAPPED 4
907777dab0Sopenharmony_ci#define CLD_STOPPED 5
917777dab0Sopenharmony_ci#define CLD_CONTINUED 6
927777dab0Sopenharmony_ci
937777dab0Sopenharmony_ciunion sigval {
947777dab0Sopenharmony_ci	int sival_int;
957777dab0Sopenharmony_ci	void *sival_ptr;
967777dab0Sopenharmony_ci};
977777dab0Sopenharmony_ci
987777dab0Sopenharmony_citypedef struct {
997777dab0Sopenharmony_ci#ifdef __SI_SWAP_ERRNO_CODE
1007777dab0Sopenharmony_ci	int si_signo, si_code, si_errno;
1017777dab0Sopenharmony_ci#else
1027777dab0Sopenharmony_ci	int si_signo, si_errno, si_code;
1037777dab0Sopenharmony_ci#endif
1047777dab0Sopenharmony_ci	union {
1057777dab0Sopenharmony_ci		char __pad[128 - 2*sizeof(int) - sizeof(long)];
1067777dab0Sopenharmony_ci		struct {
1077777dab0Sopenharmony_ci			union {
1087777dab0Sopenharmony_ci				struct {
1097777dab0Sopenharmony_ci					pid_t si_pid;
1107777dab0Sopenharmony_ci					uid_t si_uid;
1117777dab0Sopenharmony_ci				} __piduid;
1127777dab0Sopenharmony_ci				struct {
1137777dab0Sopenharmony_ci					int si_timerid;
1147777dab0Sopenharmony_ci					int si_overrun;
1157777dab0Sopenharmony_ci				} __timer;
1167777dab0Sopenharmony_ci			} __first;
1177777dab0Sopenharmony_ci			union {
1187777dab0Sopenharmony_ci				union sigval si_value;
1197777dab0Sopenharmony_ci				struct {
1207777dab0Sopenharmony_ci					int si_status;
1217777dab0Sopenharmony_ci					clock_t si_utime, si_stime;
1227777dab0Sopenharmony_ci				} __sigchld;
1237777dab0Sopenharmony_ci			} __second;
1247777dab0Sopenharmony_ci		} __si_common;
1257777dab0Sopenharmony_ci		struct {
1267777dab0Sopenharmony_ci			void *si_addr;
1277777dab0Sopenharmony_ci			short si_addr_lsb;
1287777dab0Sopenharmony_ci			union {
1297777dab0Sopenharmony_ci				struct {
1307777dab0Sopenharmony_ci					void *si_lower;
1317777dab0Sopenharmony_ci					void *si_upper;
1327777dab0Sopenharmony_ci				} __addr_bnd;
1337777dab0Sopenharmony_ci				unsigned si_pkey;
1347777dab0Sopenharmony_ci			} __first;
1357777dab0Sopenharmony_ci		} __sigfault;
1367777dab0Sopenharmony_ci		struct {
1377777dab0Sopenharmony_ci			long si_band;
1387777dab0Sopenharmony_ci			int si_fd;
1397777dab0Sopenharmony_ci		} __sigpoll;
1407777dab0Sopenharmony_ci		struct {
1417777dab0Sopenharmony_ci			void *si_call_addr;
1427777dab0Sopenharmony_ci			int si_syscall;
1437777dab0Sopenharmony_ci			unsigned si_arch;
1447777dab0Sopenharmony_ci		} __sigsys;
1457777dab0Sopenharmony_ci	} __si_fields;
1467777dab0Sopenharmony_ci} siginfo_t;
1477777dab0Sopenharmony_ci#define si_pid     __si_fields.__si_common.__first.__piduid.si_pid
1487777dab0Sopenharmony_ci#define si_uid     __si_fields.__si_common.__first.__piduid.si_uid
1497777dab0Sopenharmony_ci#define si_status  __si_fields.__si_common.__second.__sigchld.si_status
1507777dab0Sopenharmony_ci#define si_utime   __si_fields.__si_common.__second.__sigchld.si_utime
1517777dab0Sopenharmony_ci#define si_stime   __si_fields.__si_common.__second.__sigchld.si_stime
1527777dab0Sopenharmony_ci#define si_value   __si_fields.__si_common.__second.si_value
1537777dab0Sopenharmony_ci#define si_addr    __si_fields.__sigfault.si_addr
1547777dab0Sopenharmony_ci#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
1557777dab0Sopenharmony_ci#define si_lower   __si_fields.__sigfault.__first.__addr_bnd.si_lower
1567777dab0Sopenharmony_ci#define si_upper   __si_fields.__sigfault.__first.__addr_bnd.si_upper
1577777dab0Sopenharmony_ci#define si_pkey    __si_fields.__sigfault.__first.si_pkey
1587777dab0Sopenharmony_ci#define si_band    __si_fields.__sigpoll.si_band
1597777dab0Sopenharmony_ci#define si_fd      __si_fields.__sigpoll.si_fd
1607777dab0Sopenharmony_ci#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
1617777dab0Sopenharmony_ci#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
1627777dab0Sopenharmony_ci#define si_ptr     si_value.sival_ptr
1637777dab0Sopenharmony_ci#define si_int     si_value.sival_int
1647777dab0Sopenharmony_ci#define si_call_addr __si_fields.__sigsys.si_call_addr
1657777dab0Sopenharmony_ci#define si_syscall __si_fields.__sigsys.si_syscall
1667777dab0Sopenharmony_ci#define si_arch    __si_fields.__sigsys.si_arch
1677777dab0Sopenharmony_ci
1687777dab0Sopenharmony_cistruct sigaction {
1697777dab0Sopenharmony_ci	union {
1707777dab0Sopenharmony_ci		void (*sa_handler)(int);
1717777dab0Sopenharmony_ci		void (*sa_sigaction)(int, siginfo_t *, void *);
1727777dab0Sopenharmony_ci	} __sa_handler;
1737777dab0Sopenharmony_ci	sigset_t sa_mask;
1747777dab0Sopenharmony_ci	int sa_flags;
1757777dab0Sopenharmony_ci	void (*sa_restorer)(void);
1767777dab0Sopenharmony_ci};
1777777dab0Sopenharmony_ci#define sa_handler   __sa_handler.sa_handler
1787777dab0Sopenharmony_ci#define sa_sigaction __sa_handler.sa_sigaction
1797777dab0Sopenharmony_ci
1807777dab0Sopenharmony_cistruct sigevent {
1817777dab0Sopenharmony_ci	union sigval sigev_value;
1827777dab0Sopenharmony_ci	int sigev_signo;
1837777dab0Sopenharmony_ci	int sigev_notify;
1847777dab0Sopenharmony_ci	void (*sigev_notify_function)(union sigval);
1857777dab0Sopenharmony_ci	pthread_attr_t *sigev_notify_attributes;
1867777dab0Sopenharmony_ci	char __pad[56-3*sizeof(long)];
1877777dab0Sopenharmony_ci};
1887777dab0Sopenharmony_ci
1897777dab0Sopenharmony_ci#define SIGEV_SIGNAL 0
1907777dab0Sopenharmony_ci#define SIGEV_NONE 1
1917777dab0Sopenharmony_ci#define SIGEV_THREAD 2
1927777dab0Sopenharmony_ci
1937777dab0Sopenharmony_ciint __libc_current_sigrtmin(void);
1947777dab0Sopenharmony_ciint __libc_current_sigrtmax(void);
1957777dab0Sopenharmony_ci
1967777dab0Sopenharmony_ci#define SIGRTMIN  (__libc_current_sigrtmin())
1977777dab0Sopenharmony_ci#define SIGRTMAX  (__libc_current_sigrtmax())
1987777dab0Sopenharmony_ci
1997777dab0Sopenharmony_ci#define MUSL_SIGNAL_NATIVE_REMOTE (SIGRTMIN + 0)
2007777dab0Sopenharmony_ci#define MUSL_SIGNAL_HOOK (SIGRTMIN + 1)
2017777dab0Sopenharmony_ci#define MUSL_SIGNAL_UNHOOK (SIGRTMIN + 2)
2027777dab0Sopenharmony_ci#define MUSL_SIGNAL_NATIVE_LOCAL (SIGRTMIN + 3)
2037777dab0Sopenharmony_ci#define MUSL_SIGNAL_JSHEAP (SIGRTMIN + 4)
2047777dab0Sopenharmony_ci#define MUSL_SIGNAL_JSHEAP_PRIV (SIGRTMIN + 5)
2057777dab0Sopenharmony_ci
2067777dab0Sopenharmony_ciint kill(pid_t, int);
2077777dab0Sopenharmony_ciint sigemptyset(sigset_t *);
2087777dab0Sopenharmony_ciint sigfillset(sigset_t *);
2097777dab0Sopenharmony_ciint sigaddset(sigset_t *, int);
2107777dab0Sopenharmony_ciint sigdelset(sigset_t *, int);
2117777dab0Sopenharmony_ciint sigismember(const sigset_t *, int);
2127777dab0Sopenharmony_ci
2137777dab0Sopenharmony_ciint sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
2147777dab0Sopenharmony_ciint sigsuspend(const sigset_t *);
2157777dab0Sopenharmony_ciint sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
2167777dab0Sopenharmony_ciint sigpending(sigset_t *);
2177777dab0Sopenharmony_ciint sigwait(const sigset_t *__restrict, int *__restrict);
2187777dab0Sopenharmony_ciint sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
2197777dab0Sopenharmony_ciint sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
2207777dab0Sopenharmony_ciint sigqueue(pid_t, int, union sigval);
2217777dab0Sopenharmony_ci
2227777dab0Sopenharmony_ciint pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
2237777dab0Sopenharmony_ciint pthread_kill(pthread_t, int);
2247777dab0Sopenharmony_ci
2257777dab0Sopenharmony_civoid psiginfo(const siginfo_t *, const char *);
2267777dab0Sopenharmony_civoid psignal(int, const char *);
2277777dab0Sopenharmony_ci
2287777dab0Sopenharmony_ci#endif
2297777dab0Sopenharmony_ci
2307777dab0Sopenharmony_ci#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
2317777dab0Sopenharmony_ciint killpg(pid_t, int);
2327777dab0Sopenharmony_ciint sigaltstack(const stack_t *__restrict, stack_t *__restrict);
2337777dab0Sopenharmony_ciint sighold(int);
2347777dab0Sopenharmony_ciint sigignore(int);
2357777dab0Sopenharmony_ciint siginterrupt(int, int);
2367777dab0Sopenharmony_ciint sigpause(int);
2377777dab0Sopenharmony_ciint sigrelse(int);
2387777dab0Sopenharmony_civoid (*sigset(int, void (*)(int)))(int);
2397777dab0Sopenharmony_ci#define TRAP_BRKPT 1
2407777dab0Sopenharmony_ci#define TRAP_TRACE 2
2417777dab0Sopenharmony_ci#define TRAP_BRANCH 3
2427777dab0Sopenharmony_ci#define TRAP_HWBKPT 4
2437777dab0Sopenharmony_ci#define TRAP_UNK 5
2447777dab0Sopenharmony_ci#define POLL_IN 1
2457777dab0Sopenharmony_ci#define POLL_OUT 2
2467777dab0Sopenharmony_ci#define POLL_MSG 3
2477777dab0Sopenharmony_ci#define POLL_ERR 4
2487777dab0Sopenharmony_ci#define POLL_PRI 5
2497777dab0Sopenharmony_ci#define POLL_HUP 6
2507777dab0Sopenharmony_ci#define SS_ONSTACK    1
2517777dab0Sopenharmony_ci#define SS_DISABLE    2
2527777dab0Sopenharmony_ci#define SS_AUTODISARM (1U << 31)
2537777dab0Sopenharmony_ci#define SS_FLAG_BITS SS_AUTODISARM
2547777dab0Sopenharmony_ci#endif
2557777dab0Sopenharmony_ci
2567777dab0Sopenharmony_ci#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
2577777dab0Sopenharmony_ci#define NSIG _NSIG
2587777dab0Sopenharmony_citypedef void (*sig_t)(int);
2597777dab0Sopenharmony_ci#endif
2607777dab0Sopenharmony_ci
2617777dab0Sopenharmony_ci#ifdef _GNU_SOURCE
2627777dab0Sopenharmony_citypedef void (*sighandler_t)(int);
2637777dab0Sopenharmony_civoid (*bsd_signal(int, void (*)(int)))(int);
2647777dab0Sopenharmony_ci
2657777dab0Sopenharmony_ci#define SA_NOMASK SA_NODEFER
2667777dab0Sopenharmony_ci#define SA_ONESHOT SA_RESETHAND
2677777dab0Sopenharmony_ci#endif
2687777dab0Sopenharmony_ci
2697777dab0Sopenharmony_ci#define SIG_ERR  ((void (*)(int))-1)
2707777dab0Sopenharmony_ci#define SIG_DFL  ((void (*)(int)) 0)
2717777dab0Sopenharmony_ci#define SIG_IGN  ((void (*)(int)) 1)
2727777dab0Sopenharmony_ci
2737777dab0Sopenharmony_citypedef int sig_atomic_t;
2747777dab0Sopenharmony_ci
2757777dab0Sopenharmony_civoid (*signal(int, void (*)(int)))(int);
2767777dab0Sopenharmony_ciint raise(int);
2777777dab0Sopenharmony_ci
2787777dab0Sopenharmony_ci#if _REDIR_TIME64
2797777dab0Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
2807777dab0Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
2817777dab0Sopenharmony_ci || defined(_BSD_SOURCE)
2827777dab0Sopenharmony_ci__REDIR(sigtimedwait, __sigtimedwait_time64);
2837777dab0Sopenharmony_ci#endif
2847777dab0Sopenharmony_ci#endif
2857777dab0Sopenharmony_ci
2867777dab0Sopenharmony_ci#ifdef __cplusplus
2877777dab0Sopenharmony_ci}
2887777dab0Sopenharmony_ci#endif
2897777dab0Sopenharmony_ci
2907777dab0Sopenharmony_ci#endif
291