Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 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 1 2 3 4 5 6


sigset.h
001: /* __sig_atomic_t, __sigset_t, and related definitions.  Linux version.
002:    Copyright (C) 1991, 1992, 1994, 1996, 1997, 2007
003:    Free Software Foundation, Inc.
004:    This file is part of the GNU C Library.
005: 
006:    The GNU C Library is free software; you can redistribute it and/or
007:    modify it under the terms of the GNU Lesser General Public
008:    License as published by the Free Software Foundation; either
009:    version 2.1 of the License, or (at your option) any later version.
010: 
011:    The GNU C Library is distributed in the hope that it will be useful,
012:    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:    Lesser General Public License for more details.
015: 
016:    You should have received a copy of the GNU Lesser General Public
017:    License along with the GNU C Library; if not, write to the Free
018:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
019:    02111-1307 USA.  */
020: 
021: #ifndef _SIGSET_H_types
022: # define _SIGSET_H_types        1
023: 
024: typedef int __sig_atomic_t;
025: 
026: /* A `sigset_t' has a bit for each signal.  */
027: 
028: # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
029: typedef struct
030:   {
031:     unsigned long int __val[_SIGSET_NWORDS];
032:   } __sigset_t;
033: 
034: #endif
035: 
036: 
037: /* We only want to define these functions if <signal.h> was actually
038:    included; otherwise we were included just to define the types.  Since we
039:    are namespace-clean, it wouldn't hurt to define extra macros.  But
040:    trouble can be caused by functions being defined (e.g., any global
041:    register vars declared later will cause compilation errors).  */
042: 
043: #if !defined _SIGSET_H_fns && defined _SIGNAL_H
044: # define _SIGSET_H_fns 1
045: 
046: # ifndef _EXTERN_INLINE
047: #  define _EXTERN_INLINE __extern_inline
048: # endif
049: 
050: /* Return a mask that includes the bit for SIG only.  */
051: # define __sigmask(sig) \
052:   (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
053: 
054: /* Return the word index for SIG.  */
055: # define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int)))
056: 
057: # if defined __GNUC__ && __GNUC__ >= 2
058: #  define __sigemptyset(set) \
059:   (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
060:                     sigset_t *__set = (set);                                  \
061:                     while (--__cnt >= 0) __set->__val[__cnt] = 0;             \
062:                     0; }))
063: #  define __sigfillset(set) \
064:   (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
065:                     sigset_t *__set = (set);                                  \
066:                     while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;          \
067:                     0; }))
068: 
069: #  ifdef __USE_GNU
070: /* The POSIX does not specify for handling the whole signal set in one
071:    command.  This is often wanted and so we define three more functions
072:    here.  */
073: #   define __sigisemptyset(set) \
074:   (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
075:                     const sigset_t *__set = (set);                            \
076:                     int __ret = __set->__val[--__cnt];                        \
077:                     while (!__ret && --__cnt >= 0)                            \
078:                         __ret = __set->__val[__cnt];                          \
079:                     __ret == 0; }))
080: #   define __sigandset(dest, left, right) \
081:   (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
082:                     sigset_t *__dest = (dest);                                \
083:                     const sigset_t *__left = (left);                          \
084:                     const sigset_t *__right = (right);                        \
085:                     while (--__cnt >= 0)                                      \
086:                       __dest->__val[__cnt] = (__left->__val[__cnt]            \
087:                                               & __right->__val[__cnt]);       \
088:                     0; }))
089: #   define __sigorset(dest, left, right) \
090:   (__extension__ ({ int __cnt = _SIGSET_NWORDS;                               \
091:                     sigset_t *__dest = (dest);                                \
092:                     const sigset_t *__left = (left);                          \
093:                     const sigset_t *__right = (right);                        \
094:                     while (--__cnt >= 0)                                      \
095:                       __dest->__val[__cnt] = (__left->__val[__cnt]            \
096:                                               | __right->__val[__cnt]);       \
097:                     0; }))
098: #  endif
099: # endif
100: 
101: /* These functions needn't check for a bogus signal number -- error
102:    checking is done in the non __ versions.  */
103: 
104: extern int __sigismember (__const __sigset_t *, int);
105: extern int __sigaddset (__sigset_t *, int);
106: extern int __sigdelset (__sigset_t *, int);
107: 
108: # ifdef __USE_EXTERN_INLINES
109: #  define __SIGSETFN(NAME, BODY, CONST)                                       \
110:   _EXTERN_INLINE int                                                          \
111:   NAME (CONST __sigset_t *__set, int __sig)                                   \
112:   {                                                                           \
113:     unsigned long int __mask = __sigmask (__sig);                             \
114:     unsigned long int __word = __sigword (__sig);                             \
115:     return BODY;                                                              \
116:   }
117: 
118: __SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const)
119: __SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), )
120: __SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), )
121: 
122: #  undef __SIGSETFN
123: # endif
124: 
125: 
126: #endif /* ! _SIGSET_H_fns.  */
127: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/