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