diff options
Diffstat (limited to 'libphobos/libdruntime/core/sys/posix/signal.d')
-rw-r--r-- | libphobos/libdruntime/core/sys/posix/signal.d | 336 |
1 files changed, 271 insertions, 65 deletions
diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d index 574bf8c7c3a..ed3985eee4d 100644 --- a/libphobos/libdruntime/core/sys/posix/signal.d +++ b/libphobos/libdruntime/core/sys/posix/signal.d @@ -1136,55 +1136,57 @@ else version (NetBSD) enum SIG_UNBLOCK = 2; enum SIG_SETMASK = 3; - union sigval_t { - int sival_int; - void *sival_ptr; - }; - struct _rt{ - pid_t _pid; - uid_t _uid; - sigval_t _value; - }; - struct _child{ - pid_t _pid; - uid_t _uid; - int _status; - clock_t _utime; - clock_t _stime; - }; - struct _fault{ - void *_addr; - int _trap; - int _trap2; - int _trap3; - }; - struct _poll{ - long _band; - int _fd; - }; - union _reason{ - _rt rt; - _child child; - _fault fault; - _poll poll; - }; - struct _ksiginfo { + union sigval_t + { + int sival_int; + void* sival_ptr; + } + + struct _ksiginfo + { int _signo; int _code; int _errno; -/+#ifdef _LP64 - /* In _LP64 the union starts on an 8-byte boundary. */ - int _pad; -#endif+/ - _reason reason; - }; + version (D_LP64) + int _pad; + union reason_t + { + struct rt_t + { + pid_t _pid; + uid_t _uid; + sigval_t _value; + } rt_t _rt; + struct child_t + { + pid_t _pid; + uid_t _uid; + int _status; + clock_t _utime; + clock_t _stime; + } child_t _child; + struct fault_t + { + void* _addr; + int _trap; + int _trap2; + int _trap3; + } fault_t fault; + struct poll_t + { + c_long _band; + int _fd; + } poll_t _poll; + } + reason_t _reason; + } union siginfo_t { - ubyte[128] si_pad;/* Total size; for future expansion */ + ubyte[128] si_pad; _ksiginfo _info; - @property ref c_long si_band() return { return _info.reason.poll._band; } + @property ref c_long si_band() return { return _info._reason._poll._band; } } enum SI_USER = 0; @@ -1589,27 +1591,53 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - struct sigset_t { - ulong[128/long.sizeof] __bits; + struct sigset_t + { + c_ulong[128/c_long.sizeof] __bits; } - enum SIG_BLOCK = 0; - enum SIG_UNBLOCK = 1; - enum SIG_SETMASK = 2; + version (MIPS_Any) + { + enum SIG_BLOCK = 1; + enum SIG_UNBLOCK = 2; + enum SIG_SETMASK = 3; + } + else + { + enum SIG_BLOCK = 0; + enum SIG_UNBLOCK = 1; + enum SIG_SETMASK = 2; + } - struct siginfo_t { - int si_signo, si_errno, si_code; - union __si_fields_t { - char[128 - 2*int.sizeof - long.sizeof] __pad = 0; - struct __si_common_t { - union __first_t { - struct __piduid_t { + struct siginfo_t + { + int si_signo; + version (MIPS_Any) // __SI_SWAP_ERRNO_CODE + { + int si_code; + int si_errno; + } + else + { + int si_errno; + int si_code; + } + union __si_fields_t + { + char[128 - 2*int.sizeof - c_long.sizeof] __pad = 0; + struct __si_common_t + { + union __first_t + { + struct __piduid_t + { pid_t si_pid; uid_t si_uid; } __piduid_t __piduid; - struct __timer_t { + struct __timer_t + { int si_timerid; int si_overrun; } @@ -1617,11 +1645,14 @@ else version (CRuntime_Musl) } __first_t __first; - union __second_t { + union __second_t + { sigval si_value; - struct __sigchld_t { + struct __sigchld_t + { int si_status; - clock_t si_utime, si_stime; + clock_t si_utime; + clock_t si_stime; } __sigchld_t __sigchld; } @@ -1629,11 +1660,14 @@ else version (CRuntime_Musl) } __si_common_t __si_common; - struct __sigfault_t { + struct __sigfault_t + { void *si_addr; short si_addr_lsb; - union __first_t { - struct __addr_bnd_t { + union __first_t + { + struct __addr_bnd_t + { void *si_lower; void *si_upper; } @@ -1644,13 +1678,15 @@ else version (CRuntime_Musl) } __sigfault_t __sigfault; - struct __sigpoll_t { - long si_band; + struct __sigpoll_t + { + c_long si_band; int si_fd; } __sigpoll_t __sigpoll; - struct __sigsys_t { + struct __sigsys_t + { void *si_call_addr; int si_syscall; uint si_arch; @@ -3030,7 +3066,177 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - enum SA_RESTART = 0x10000000; + version (MIPS_Any) + { + enum SIGPOLL = 22; + enum SIGPROF = 29; + enum SIGSYS = 12; + enum SIGTRAP = 5; + enum SIGVTALRM = 28; + enum SIGXCPU = 30; + enum SIGXFSZ = 31; + + enum SA_ONSTACK = 0x08000000; + enum SA_RESETHAND = 0x80000000; + enum SA_RESTART = 0x10000000; + enum SA_SIGINFO = 8; + enum SA_NOCLDWAIT = 0x10000; + enum SA_NODEFER = 0x40000000; + } + else + { + enum SIGPOLL = 29; + enum SIGPROF = 27; + enum SIGSYS = 31; + enum SIGTRAP = 5; + enum SIGVTALRM = 26; + enum SIGXCPU = 24; + enum SIGXFSZ = 25; + + enum SA_ONSTACK = 0x08000000; + enum SA_RESETHAND = 0x80000000; + enum SA_RESTART = 0x10000000; + enum SA_SIGINFO = 4; + enum SA_NOCLDWAIT = 2; + enum SA_NODEFER = 0x40000000; + } + + enum SS_ONSTACK = 1; + enum SS_DISABLE = 2; + + version (ARM) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } + else version (AArch64) + { + enum MINSIGSTKSZ = 6144; + enum SIGSTKSZ = 12288; + } + else version (IBMZ_Any) + { + enum MINSIGSTKSZ = 4096; + enum SIGSTKSZ = 10240; + } + else version (MIPS_Any) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } + else version (PPC_Any) + { + enum MINSIGSTKSZ = 4096; + enum SIGSTKSZ = 10240; + } + else version (X86_Any) + { + enum MINSIGSTKSZ = 2048; + enum SIGSTKSZ = 8192; + } + else + static assert(0, "unimplemented"); + + //ucontext_t (defined in core.sys.posix.ucontext) + //mcontext_t (defined in core.sys.posix.ucontext) + + version (MIPS_Any) + { + struct stack_t + { + void* ss_sp; + size_t ss_size; + int ss_flags; + } + } + else + { + struct stack_t + { + void* ss_sp; + int ss_flags; + size_t ss_size; + } + } + + enum + { + ILL_ILLOPC = 1, + ILL_ILLOPN, + ILL_ILLADR, + ILL_ILLTRP, + ILL_PRVOPC, + ILL_PRVREG, + ILL_COPROC, + ILL_BADSTK + } + + enum + { + FPE_INTDIV = 1, + FPE_INTOVF, + FPE_FLTDIV, + FPE_FLTOVF, + FPE_FLTUND, + FPE_FLTRES, + FPE_FLTINV, + FPE_FLTSUB + } + + enum + { + SEGV_MAPERR = 1, + SEGV_ACCERR + } + + enum + { + BUS_ADRALN = 1, + BUS_ADRERR, + BUS_OBJERR + } + + enum + { + TRAP_BRKPT = 1, + TRAP_TRACE + } + + enum + { + CLD_EXITED = 1, + CLD_KILLED, + CLD_DUMPED, + CLD_TRAPPED, + CLD_STOPPED, + CLD_CONTINUED + } + + enum + { + POLL_IN = 1, + POLL_OUT, + POLL_MSG, + POLL_ERR, + POLL_PRI, + POLL_HUP + } + + sigfn_t bsd_signal(int sig, sigfn_t func); + sigfn_t sigset(int sig, sigfn_t func); + + nothrow: + @nogc: + sigfn_t2 bsd_signal(int sig, sigfn_t2 func); + sigfn_t2 sigset(int sig, sigfn_t2 func); + + int killpg(pid_t, int); + int sigaltstack(const scope stack_t*, stack_t*); + int sighold(int); + int sigignore(int); + int siginterrupt(int, int); + int sigpause(int); + int sigrelse(int); } else version (CRuntime_UClibc) { @@ -3485,7 +3691,7 @@ else version (CRuntime_Musl) int sigev_notify; void function(sigval) sigev_notify_function; pthread_attr_t *sigev_notify_attributes; - char[56 - 3 * long.sizeof] __pad = void; + char[56 - 3 * c_long.sizeof] __pad = void; } } else version (CRuntime_UClibc) |