| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- /*
- * Copyright (c) mlibc & plct lab
- *
- * SPDX-License-Identifier: MIT
- *
- * Change Logs:
- * Date Author Notes
- * 2023/06/16 bernard the first verison
- */
- #ifndef __SYS_SIGNAL_H__
- #ifndef MLIBC_SIGNAL_H__
- #define MLIBC_SIGNAL_H__
- #include <stdint.h>
- #include <time.h>
- #ifndef SIGHUP
- #define SIGHUP 1
- #endif
- #ifndef SIGINT
- #define SIGINT 2
- #endif
- #ifndef SIGQUIT
- #define SIGQUIT 3
- #endif
- #ifndef SIGBUS
- #define SIGBUS 7
- #endif
- #ifndef SIGFPE
- #define SIGFPE 8
- #endif
- #ifndef SIGKILL
- #define SIGKILL 9
- #endif
- #ifndef SIGUSR1
- #define SIGUSR1 10
- #endif
- #ifndef SIGSEGV
- #define SIGSEGV 11
- #endif
- #ifndef SIGUSR2
- #define SIGUSR2 12
- #endif
- #ifndef SIGPIPE
- #define SIGPIPE 13
- #endif
- #ifndef SIGALRM
- #define SIGALRM 14
- #endif
- #ifndef SIGTERM
- #define SIGTERM 15
- #endif
- #ifndef SIGSTKFLT
- #define SIGSTKFLT 16
- #endif
- #ifndef SIGCHLD
- #define SIGCHLD 17
- #endif
- #ifndef SIGCONT
- #define SIGCONT 18
- #endif
- #ifndef SIGSTOP
- #define SIGSTOP 19
- #endif
- #ifndef SIGTSTP
- #define SIGTSTP 20
- #endif
- #ifndef SIGTTIN
- #define SIGTTIN 21
- #endif
- #ifndef SIGTTOU
- #define SIGTTOU 22
- #endif
- #ifndef SIGURG
- #define SIGURG 23
- #endif
- #ifndef SIGXCPU
- #define SIGXCPU 24
- #endif
- #ifndef SIGXFSZ
- #define SIGXFSZ 25
- #endif
- #ifndef SIGVTALRM
- #define SIGVTALRM 26
- #endif
- #ifndef SIGPROF
- #define SIGPROF 27
- #endif
- #ifndef SIGWINCH
- #define SIGWINCH 28
- #endif
- #ifndef SIGIO
- #define SIGIO 29
- #endif
- #ifndef SIGPOLL
- #define SIGPOLL 29
- #endif
- #ifndef SIGPWR
- #define SIGPWR 30
- #endif
- #ifndef SIGSYS
- #define SIGSYS 31
- #endif
- #ifndef SIGUNUSED
- #define SIGUNUSED SIGSYS
- #endif
- #ifndef SA_NOCLDSTOP
- #define SA_NOCLDSTOP 1
- #endif
- #ifndef SA_NOCLDWAIT
- #define SA_NOCLDWAIT 2
- #endif
- #ifndef SA_SIGINFO
- #define SA_SIGINFO 4
- #endif
- #ifndef SA_ONSTACK
- #define SA_ONSTACK 0x08000000
- #endif
- #ifndef SA_RESTART
- #define SA_RESTART 0x10000000
- #endif
- #ifndef SA_NODEFER
- #define SA_NODEFER 0x40000000
- #endif
- #ifndef SA_RESETHAND
- #define SA_RESETHAND 0x80000000
- #endif
- #ifndef SA_RESTORER
- #define SA_RESTORER 0x04000000
- #endif
- #ifndef _NSIG
- #define _NSIG 65
- #endif
- #ifndef SI_KERNEL
- #define SI_KERNEL 128
- #endif
- #ifndef SIG_SETMASK
- #define SIG_SETMASK 0 /* set mask with sigprocmask() */
- #endif
- #ifndef SIG_BLOCK
- #define SIG_BLOCK 1 /* set of signals to block */
- #endif
- #ifndef SIG_UNBLOCK
- #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
- #endif
- #ifndef _SIG_FUNC_PTR_DEFINED
- typedef void (*_sig_func_ptr)(int);
- #define _SIG_FUNC_PTR_DEFINED
- #endif
- #ifndef _SIGSET_T_DEFINED
- typedef unsigned long sigset_t;
- #define _SIGSET_T_DEFINED
- #endif
- #ifndef SIG_DFL
- #define SIG_DFL ((_sig_func_ptr)0) /* Default action */
- #endif
- #ifndef SIG_IGN
- #define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */
- #endif
- #ifndef SIG_ERR
- #define SIG_ERR ((_sig_func_ptr)-1) /* Error return */
- #endif
- #ifndef SI_USER
- #define SI_USER 0x01 /* Signal sent by kill(). */
- #endif
- #ifndef SI_QUEUE
- #define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
- #endif
- #ifndef SI_TIMER
- #define SI_TIMER 0x03 /* Signal generated by expiration of a
- timer set by timer_settime(). */
- #endif
- #ifndef SI_ASYNCIO
- #define SI_ASYNCIO 0x04 /* Signal generated by completion of an
- asynchronous I/O request. */
- #endif
- #ifndef SI_MESGQ
- #define SI_MESGQ 0x05 /* Signal generated by arrival of a
- message on an empty message queue. */
- #endif
- #ifndef CLD_EXITED
- #define CLD_EXITED 1
- #endif
- #ifndef CLD_KILLED
- #define CLD_KILLED 2
- #endif
- #ifndef CLD_DUMPED
- #define CLD_DUMPED 3
- #endif
- #ifndef CLD_TRAPPED
- #define CLD_TRAPPED 4
- #endif
- #ifndef CLD_STOPPED
- #define CLD_STOPPED 5
- #endif
- #ifndef CLD_CONTINUED
- #define CLD_CONTINUED 6
- #endif
- #ifndef SIGEV_SIGNAL
- #define SIGEV_SIGNAL 0
- #endif
- #ifndef SIGEV_NONE
- #define SIGEV_NONE 1
- #endif
- #ifndef SIGEV_THREAD
- #define SIGEV_THREAD 2
- #endif
- #ifndef SIGEV_THREAD_ID
- #define SIGEV_THREAD_ID 4
- #endif
- #ifndef _UNION_SIGVAL_DEFINED
- union sigval
- {
- int sival_int; /* Integer signal value */
- void *sival_ptr; /* Pointer signal value */
- };
- #define _UNION_SIGVAL_DEFINED
- #endif
- #ifndef _STRUCT_SIGACTION_DEFINED
- struct sigaction
- {
- _sig_func_ptr sa_handler;
- sigset_t sa_mask;
- int sa_flags;
- };
- #define _STRUCT_SIGACTION_DEFINED
- #endif
- #ifndef _STRUCT_SIGEVENT_DEFINED
- struct sigevent
- {
- union sigval sigev_value;
- int sigev_signo; /* Signal number */
- int sigev_notify; /* Notification type */
- void (*sigev_notify_function)( union sigval );
- /* Notification function */
- void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
- };
- #define _STRUCT_SIGEVENT_DEFINED
- #endif
- #ifndef _SIGINFO_T_DEFINED
- typedef struct {
- int si_signo, si_errno, si_code;
- union {
- char __pad[128 - 2*sizeof(int) - sizeof(long)];
- struct {
- union {
- struct {
- pid_t si_pid;
- uid_t si_uid;
- } __piduid;
- struct {
- int si_timerid;
- int si_overrun;
- } __timer;
- } __first;
- union {
- union sigval si_value;
- struct {
- int si_status;
- clock_t si_utime, si_stime;
- } __sigchld;
- } __second;
- } __si_common;
- struct {
- void *si_addr;
- short si_addr_lsb;
- union {
- struct {
- void *si_lower;
- void *si_upper;
- } __addr_bnd;
- unsigned si_pkey;
- } __first;
- } __sigfault;
- struct {
- long si_band;
- int si_fd;
- } __sigpoll;
- struct {
- void *si_call_addr;
- int si_syscall;
- unsigned si_arch;
- } __sigsys;
- } __si_fields;
- } siginfo_t;
- #define _SIGINFO_T_DEFINED
- #endif
- #define si_pid __si_fields.__si_common.__first.__piduid.si_pid
- #define si_uid __si_fields.__si_common.__first.__piduid.si_uid
- #define si_status __si_fields.__si_common.__second.__sigchld.si_status
- #define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
- #define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
- #define si_value __si_fields.__si_common.__second.si_value
- #define si_addr __si_fields.__sigfault.si_addr
- #define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
- #define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
- #define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
- #define si_pkey __si_fields.__sigfault.__first.si_pkey
- #define si_band __si_fields.__sigpoll.si_band
- #define si_fd __si_fields.__sigpoll.si_fd
- #define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
- #define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
- #define si_ptr si_value.sival_ptr
- #define si_int si_value.sival_int
- #define si_call_addr __si_fields.__sigsys.si_call_addr
- #define si_syscall __si_fields.__sigsys.si_syscall
- #define si_arch __si_fields.__sigsys.si_arch
- #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
- int sigprocmask(int how, const sigset_t *set, sigset_t *oset);
- #ifndef sigemptyset
- int sigemptyset(sigset_t *set);
- #endif
- int sigwait(const sigset_t *set, int *sig);
- int raise(int sig);
- #endif /*MLIBC_SIGNAL_H__*/
- #endif /*__SYS_SIGNAL_H__*/
|