| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* __sig_atomic_t, __sigset_t, and related definitions.  Generic/BSD version. | 
|  | 2 | Copyright (C) 1991-2016 Free Software Foundation, Inc. | 
|  | 3 | This file is part of the GNU C Library. | 
|  | 4 |  | 
|  | 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. | 
|  | 9 |  | 
|  | 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. | 
|  | 14 |  | 
|  | 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 | <http://www.gnu.org/licenses/>.  */ | 
|  | 18 |  | 
|  | 19 | #ifndef	_SIGSET_H_types | 
|  | 20 | #define	_SIGSET_H_types	1 | 
|  | 21 |  | 
|  | 22 | typedef int __sig_atomic_t; | 
|  | 23 |  | 
|  | 24 | /* A `sigset_t' has a bit for each signal.  */ | 
|  | 25 | typedef unsigned long int __sigset_t; | 
|  | 26 |  | 
|  | 27 | #endif | 
|  | 28 |  | 
|  | 29 |  | 
|  | 30 | /* We only want to define these functions if <signal.h> was actually | 
|  | 31 | included; otherwise we were included just to define the types.  Since we | 
|  | 32 | are namespace-clean, it wouldn't hurt to define extra macros.  But | 
|  | 33 | trouble can be caused by functions being defined (e.g., any global | 
|  | 34 | register vars declared later will cause compilation errors).  */ | 
|  | 35 |  | 
|  | 36 | #if !defined _SIGSET_H_fns && defined _SIGNAL_H | 
|  | 37 | #define _SIGSET_H_fns 1 | 
|  | 38 |  | 
|  | 39 | #ifndef _EXTERN_INLINE | 
|  | 40 | # define _EXTERN_INLINE __extern_inline | 
|  | 41 | #endif | 
|  | 42 |  | 
|  | 43 | /* Return a mask that includes SIG only.  The cast to `sigset_t' avoids | 
|  | 44 | overflow if `sigset_t' is wider than `int'.  */ | 
|  | 45 | #define	__sigmask(sig)	(((__sigset_t) 1) << ((sig) - 1)) | 
|  | 46 |  | 
|  | 47 | #define	__sigemptyset(set)	\ | 
|  | 48 | (__extension__ ({ *(set) = (__sigset_t) 0; 0; }) | 
|  | 49 | #define	__sigfillset(set)	\ | 
|  | 50 | (__extension__ ({ *(set) = ~(__sigset_t) 0; 0; })) | 
|  | 51 |  | 
|  | 52 | #ifdef _GNU_SOURCE | 
|  | 53 | # define __sigisemptyset(set)	(*(set) == (__sigset_t) 0) | 
|  | 54 | # define __sigandset(dest, left, right) \ | 
|  | 55 | (__extension__ ({ *(dest) = *(left) & *(right); 0; })) | 
|  | 56 | # define __sigorset(dest, left, right) \ | 
|  | 57 | (__extension__ ({ *(dest) = *(left) | *(right); 0; })) | 
|  | 58 | #endif | 
|  | 59 |  | 
|  | 60 | /* These functions needn't check for a bogus signal number -- error | 
|  | 61 | checking is done in the non __ versions.  */ | 
|  | 62 |  | 
|  | 63 | extern int __sigismember (const __sigset_t *, int); | 
|  | 64 | extern int __sigaddset (__sigset_t *, int); | 
|  | 65 | extern int __sigdelset (__sigset_t *, int); | 
|  | 66 |  | 
|  | 67 | #ifdef __USE_EXTERN_INLINES | 
|  | 68 | # define __SIGSETFN(NAME, BODY, CONST)					      \ | 
|  | 69 | _EXTERN_INLINE int							      \ | 
|  | 70 | NAME (CONST __sigset_t *__set, int __sig)				      \ | 
|  | 71 | {									      \ | 
|  | 72 | __sigset_t __mask = __sigmask (__sig);				      \ | 
|  | 73 | return BODY;							      \ | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 | __SIGSETFN (__sigismember, (*__set & __mask) ? 1 : 0, const) | 
|  | 77 | __SIGSETFN (__sigaddset, ((*__set |= __mask), 0), ) | 
|  | 78 | __SIGSETFN (__sigdelset, ((*__set &= ~__mask), 0), ) | 
|  | 79 |  | 
|  | 80 | # undef __SIGSETFN | 
|  | 81 | #endif | 
|  | 82 |  | 
|  | 83 |  | 
|  | 84 | #endif /* ! _SIGSET_H_fns.  */ |