isblank() implementation.
[minix.git] / lib / libc / posix / _sigset.c
bloba1813cf93e7dcdcffcaa508c6078608674f54865
1 #include <lib.h>
2 /* System processes use simpler macros with no range error checking (defined in
3 * signal.h). The ANSI signal() implementation now also uses the macro
4 * versions, which makes hiding of the functions here a historical remains.
6 * _NSIG is supposed to be the highest signal number plus one.
7 */
8 #define sigaddset _sigaddset
9 #define sigdelset _sigdelset
10 #define sigemptyset _sigemptyset
11 #define sigfillset _sigfillset
12 #define sigismember _sigismember
13 #include <signal.h>
15 /* Low bit of signal masks. */
16 #define SIGBIT_0 ((sigset_t) 1)
18 /* Mask of valid signals (0 - (_NSIG-1)). */
19 #define SIGMASK ((SIGBIT_0 << _NSIG) - 1)
21 #define sigisvalid(signo) ((unsigned) (signo) < _NSIG)
23 PUBLIC int sigaddset(set, signo)
24 sigset_t *set;
25 int signo;
27 if (!sigisvalid(signo)) {
28 errno = EINVAL;
29 return -1;
31 *set |= SIGBIT_0 << signo;
32 return 0;
35 PUBLIC int sigdelset(set, signo)
36 sigset_t *set;
37 int signo;
39 if (!sigisvalid(signo)) {
40 errno = EINVAL;
41 return -1;
43 *set &= ~(SIGBIT_0 << signo);
44 return 0;
47 PUBLIC int sigemptyset(set)
48 sigset_t *set;
50 *set = 0;
51 return 0;
54 PUBLIC int sigfillset(set)
55 sigset_t *set;
57 *set = SIGMASK;
58 return 0;
61 PUBLIC int sigismember(set, signo)
62 _CONST sigset_t *set;
63 int signo;
65 if (!sigisvalid(signo)) {
66 errno = EINVAL;
67 return -1;
69 if (*set & (SIGBIT_0 << signo))
70 return 1;
71 return 0;