source: trunk/minix/lib/posix/_sigset.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.6 KB
Line 
1#include <lib.h>
2/* XXX - these have to be hidden because signal() uses them and signal() is
3 * ANSI and not POSIX. It would be surely be better to use macros for the
4 * library and system uses, and perhaps macros as well as functions for the
5 * POSIX user interface. The macros would not need underlines. It may be
6 * inconvenient to match the exact semantics of the current functions
7 * because the interface is bloated by reporting errors. For library and
8 * system uses, the signal number is mostly already known to be valid
9 * before the sigset-changing routines are called.
10 */
11#define sigaddset _sigaddset
12#define sigdelset _sigdelset
13#define sigemptyset _sigemptyset
14#define sigfillset _sigfillset
15#define sigismember _sigismember
16#include <signal.h>
17
18/* Low bit of signal masks. */
19#define SIGBIT_0 ((sigset_t) 1)
20
21/* Mask of valid signals (0 - _NSIG). */
22#define SIGMASK (((SIGBIT_0 << _NSIG) << 1) - 1)
23
24#define sigisvalid(signo) ((unsigned) (signo) <= _NSIG)
25
26PUBLIC int sigaddset(set, signo)
27sigset_t *set;
28int signo;
29{
30 if (!sigisvalid(signo)) {
31 errno = EINVAL;
32 return -1;
33 }
34 *set |= SIGBIT_0 << signo;
35 return 0;
36}
37
38PUBLIC int sigdelset(set, signo)
39sigset_t *set;
40int signo;
41{
42 if (!sigisvalid(signo)) {
43 errno = EINVAL;
44 return -1;
45 }
46 *set &= ~(SIGBIT_0 << signo);
47 return 0;
48}
49
50PUBLIC int sigemptyset(set)
51sigset_t *set;
52{
53 *set = 0;
54 return 0;
55}
56
57PUBLIC int sigfillset(set)
58sigset_t *set;
59{
60 *set = SIGMASK;
61 return 0;
62}
63
64PUBLIC int sigismember(set, signo)
65_CONST sigset_t *set;
66int signo;
67{
68 if (!sigisvalid(signo)) {
69 errno = EINVAL;
70 return -1;
71 }
72 if (*set & (SIGBIT_0 << signo))
73 return 1;
74 return 0;
75}
Note: See TracBrowser for help on using the repository browser.