1 /* Internal sigset_t definition.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _INTERNAL_SIGSET_H
20 #define _INTERNAL_SIGSET_H
22 #include <sigsetops.h>
26 unsigned long int __val
[__NSIG_WORDS
];
30 internal_sigset_from_sigset (internal_sigset_t
*iset
, const sigset_t
*set
)
32 int cnt
= __NSIG_WORDS
;
34 iset
->__val
[cnt
] = set
->__val
[cnt
];
38 internal_sigemptyset (internal_sigset_t
*set
)
40 int cnt
= __NSIG_WORDS
;
46 internal_sigfillset (internal_sigset_t
*set
)
48 int cnt
= __NSIG_WORDS
;
50 set
->__val
[cnt
] = ~0UL;
54 internal_sigisemptyset (const internal_sigset_t
*set
)
56 int cnt
= __NSIG_WORDS
;
57 int ret
= set
->__val
[--cnt
];
58 while (ret
== 0 && --cnt
>= 0)
59 ret
= set
->__val
[cnt
];
64 internal_sigandset (internal_sigset_t
*dest
, const internal_sigset_t
*left
,
65 const internal_sigset_t
*right
)
67 int cnt
= __NSIG_WORDS
;
69 dest
->__val
[cnt
] = left
->__val
[cnt
] & right
->__val
[cnt
];
73 internal_sigorset (internal_sigset_t
*dest
, const internal_sigset_t
*left
,
74 const internal_sigset_t
*right
)
76 int cnt
= __NSIG_WORDS
;
78 dest
->__val
[cnt
] = left
->__val
[cnt
] | right
->__val
[cnt
];
82 internal_sigismember (const internal_sigset_t
*set
, int sig
)
84 unsigned long int mask
= __sigmask (sig
);
85 unsigned long int word
= __sigword (sig
);
86 return set
->__val
[word
] & mask
? 1 : 0;
90 internal_sigaddset (internal_sigset_t
*set
, int sig
)
92 unsigned long int mask
= __sigmask (sig
);
93 unsigned long int word
= __sigword (sig
);
94 set
->__val
[word
] |= mask
;
98 internal_sigdelset (internal_sigset_t
*set
, int sig
)
100 unsigned long int mask
= __sigmask (sig
);
101 unsigned long int word
= __sigword (sig
);
102 set
->__val
[word
] &= ~mask
;
105 #endif /* _INTERNAL_SIGSET_H */