%{#
#include "libc/CATS/signal.cats"
%}
staload TYPES = "libc/sys/SATS/types.sats"
typedef pid_t = $TYPES.pid_t
typedef uid_t = $TYPES.uid_t
typedef clock_t = $TYPES.clock_t
staload PTHREAD = "libc/SATS/pthread.sats"
typedef pthread_t = $PTHREAD.pthread_t
abst@ype signum_t = $extype "signum_t"
macdef SIGHUP = $extval (signum_t, "SIGHUP") macdef SIGINT = $extval (signum_t, "SIGINT") macdef SIGQUIT = $extval (signum_t, "SIGQUIT") macdef SIGILL = $extval (signum_t, "SIGILL") macdef SIGABRT = $extval (signum_t, "SIGABRT") macdef SIGFPE = $extval (signum_t, "SIGFPE") macdef SIGKILL = $extval (signum_t, "SIGKILL") macdef SIGSEGV = $extval (signum_t, "SIGSEGV") macdef SIGPIPE = $extval (signum_t, "SIGPIPE") macdef SIGALRM = $extval (signum_t, "SIGALRM") macdef SIGTERM = $extval (signum_t, "SIGTERM") macdef SIGUSR1 = $extval (signum_t, "SIGUSR1")
macdef SIGUSR2 = $extval (signum_t, "SIGUSR2")
macdef SIGCHLD = $extval (signum_t, "SIGCHLD")
macdef SIGCONT = $extval (signum_t, "SIGCONT")
macdef SIGSTOP = $extval (signum_t, "SIGSTOP")
macdef SIGTSTP = $extval (signum_t, "SIGTSTP")
macdef SIGTTIN = $extval (signum_t, "SIGTTIN")
macdef SIGTTOU = $extval (signum_t, "SIGTTOU")
macdef SIGBUS = $extval (signum_t, "SIGBUS")
macdef SIGTRAP = $extval (signum_t, "SIGTRAP") macdef SIGIO = $extval (signum_t, "SIGIO")
abstype sighandler_t macdef SIG_DFL = $extval (sighandler_t, "SIG_DFL")
macdef SIG_IGN = $extval (sighandler_t, "SIG_IGN")
macdef SIG_HOLD = $extval (sighandler_t, "SIG_HOLD")
macdef SIG_ERR = $extval (sighandler_t, "SIG_ERR")
symintr sighandler
castfn sighandler_of_fun (f: signum_t -<fun1> void): sighandler_t
overload sighandler with sighandler_of_fun
abst@ype sigset_t = $extype "sigset_t"
fun sigemptyset (set: &sigset_t? >> opt (sigset_t, i==0))
: #[i:int | i <= 0] int (i) = "#atslib_sigemptyset"
fun sigfillset (set: &sigset_t? >> opt (sigset_t, i==0))
: #[i:int | i <= 0] int (i) = "#atslib_sigfillset"
fun sigaddset (set: &sigset_t, sgn: signum_t): int = "#atslib_sigaddset"
fun sigdelset (set: &sigset_t, sgn: signum_t): int = "#atslib_sigdelset"
fun sigismember (set: &sigset_t, sgn: signum_t): int = "#atslib_sigismember"
abst@ype sigmaskhow_t = int
macdef SIG_BLOCK = $extval (sigmaskhow_t, "SIG_BLOCK")
macdef SIG_SETMASK = $extval (sigmaskhow_t, "SIG_SETMASK")
macdef SIG_NONBLOCK = $extval (sigmaskhow_t, "SIG_NONBLOCK")
fun pthread_sigmask (
how: sigmaskhow_t
, newset: &sigset_t, oldset: &sigset_t? >> opt (sigset_t, i==0)
) : #[i:int | i <= 0] int (i) = "#atslib_pthread_sigmask"
fun pthread_sigmask_null
(how: sigmaskhow_t, newset: &sigset_t): int = "#atslib_pthread_sigmask"
fun sigprocmask (
how: sigmaskhow_t
, newset: &sigset_t, oldset: &sigset_t? >> opt (sigset_t, i==0)
) : #[i:int | i <= 0] int (i) = "#atslib_sigprocmask"
fun sigprocmask_null
(how: sigmaskhow_t, newset: &sigset_t): int = "#atslib_sigprocmask_null"
abst@ype sigval_t = $extype "sigval_t"
abst@ype saflag_t = uint
macdef SA_NOCLDSTOP = $extval (saflag_t, "SA_NOCLDSTOP")
macdef SA_NOCLDWAIT = $extval (saflag_t, "SA_NOCLDWAIT")
macdef SA_NODEFER = $extval (saflag_t, "SA_NODEFER")
macdef SA_ONSTACK = $extval (saflag_t, "SA_ONSTACK")
macdef SA_RESETHAND = $extval (saflag_t, "SA_RESETHAND")
macdef SA_RESTART = $extval (saflag_t, "SA_RESTART")
macdef SA_SIGINFO = $extval (saflag_t, "SA_SIGINFO")
typedef siginfo_t =
$extype_struct "siginfo_t" of {
si_signo= int , si_sigerror= int , si_code= int , si_trapno= int , si_pid= pid_t , si_uid= uid_t , si_status= int , si_utime= clock_t , si_stime= clock_t , si_value= sigval_t , si_int= int , si_ptr= ptr , si_overrun= int , si_timerid= int , si_addr= ptr , si_band= int , si_fd= int }
fun signal
(sgn: signum_t, act: sighandler_t): sighandler_t = "#atslib_signal"
fun sigset
(sgn: signum_t, act: sighandler_t): sighandler_t = "#atslib_sigset"
fun sigrelse (sgn: signum_t): int = "#atslib_sigrelse"
fun sighold (sgn: signum_t): int = "#atslib_sighold"
fun sigignore (sgn: signum_t): int = "#atslib_sigignore"
typedef sigaction_struct =
$extype_struct "ats_sigaction_type" of {
sa_handler= sighandler_t
, sa_sigaction= (int, &siginfo_t, ptr) -<fun1> void
, sa_mask= sigset_t
, sa_flags= saflag_t
, sa_restorer= () -<fun1> void
} typedef sigaction = sigaction_struct
fun sigaction (
sgn: signum_t
, newact: &sigaction, oldact: &sigaction? >> opt (sigaction, i==0)
) : #[i:int | i <= 0] int i = "#atslib_sigaction" fun sigaction_null
(sgn: signum_t, newact: &sigaction): int = "#atslib_sigaction_null"
fun kill (proc: pid_t, sgn: signum_t): int = "#atslib_kill"
fun killpg (pgrp: pid_t, sgn: signum_t): int = "#atslib_killpg"
fun pthread_kill (tid: pthread_t, sgn: signum_t): int = "#atslib_pthread_kill"
fun raise (sgn: signum_t): int = "#atslib_raise"
fun sigwait ( set: &sigset_t, sgn: &signum_t? >> opt (signum_t, i==0)
) : #[i:int | i >= 0] int(i) = "#atslib_sigwait"
fun sigpause (sgn: signum_t): int = "#atslib_pause"
fun sigsuspend (mask: &sigset_t): int = "#atslib_sigsuspend"
fun sigpending ( set: &sigset_t? >> opt (sigset_t, i==0)
) : #[i:int | i <= 0] int i = "#atslib_sigpending"
fun siginterrupt (sgn: signum_t, flag: int): int = "#atslib_siginterrupt"