ref: 5ebb1a29d8250027e8b7f2287f3bfa3a6f3d13ac
dir: /sys/src/ape/lib/ap/posix/sigset.c/
#include <signal.h> #include <errno.h> /* * sigsets are 32-bit longs. if the 2<<(i-1) bit is on, * the signal #define'd as i in signal.h is inluded. */ static sigset_t stdsigs = SIGHUP|SIGINT|SIGQUIT|SIGILL|SIGABRT|SIGFPE|SIGKILL| SIGSEGV|SIGPIPE|SIGALRM|SIGTERM|SIGUSR1|SIGUSR2; #define BITSIG(s) (2<<(s)) int sigemptyset(sigset_t *set) { *set = 0; return 0; } int sigfillset(sigset_t *set) { *set = stdsigs; return 0; } int sigaddset(sigset_t *set, int signo) { int b; b = BITSIG(signo); if(!(b&stdsigs)){ errno = EINVAL; return -1; } *set |= b; return 0; } int sigdelset(sigset_t *set, int signo) { int b; b = BITSIG(signo); if(!(b&stdsigs)){ errno = EINVAL; return -1; } *set &= ~b; return 0; } int sigismember(sigset_t *set, int signo) { int b; b = BITSIG(signo); if(!(b&stdsigs)){ errno = EINVAL; return -1; } return (b&*set)? 1 : 0; }