diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/lib/ap/posix/sigset.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/lib/ap/posix/sigset.c')
-rwxr-xr-x | sys/src/ape/lib/ap/posix/sigset.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/sys/src/ape/lib/ap/posix/sigset.c b/sys/src/ape/lib/ap/posix/sigset.c new file mode 100755 index 000000000..1a9ef12aa --- /dev/null +++ b/sys/src/ape/lib/ap/posix/sigset.c @@ -0,0 +1,67 @@ +#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; +} |