modernc.org/cc@v1.0.1/v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigset.h (about)

     1  /* __sig_atomic_t, __sigset_t, and related definitions.  Linux 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  
    26  #define _SIGSET_NWORDS	(1024 / (8 * sizeof (unsigned long int)))
    27  typedef struct {
    28  	unsigned long int __val[_SIGSET_NWORDS];
    29  } __sigset_t;
    30  
    31  #endif
    32  
    33  /* We only want to define these functions if <signal.h> was actually
    34     included; otherwise we were included just to define the types.  Since we
    35     are namespace-clean, it wouldn't hurt to define extra macros.  But
    36     trouble can be caused by functions being defined (e.g., any global
    37     register vars declared later will cause compilation errors).  */
    38  
    39  #if !defined _SIGSET_H_fns && defined _SIGNAL_H
    40  #define _SIGSET_H_fns 1
    41  
    42  #ifndef _EXTERN_INLINE
    43  #define _EXTERN_INLINE __extern_inline
    44  #endif
    45  
    46  /* Return a mask that includes the bit for SIG only.  */
    47  #define __sigmask(sig) \
    48    (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
    49  
    50  /* Return the word index for SIG.  */
    51  #define __sigword(sig)	(((sig) - 1) / (8 * sizeof (unsigned long int)))
    52  
    53  #if defined __GNUC__ && __GNUC__ >= 2
    54  #define __sigemptyset(set) \
    55    (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
    56  		    sigset_t *__set = (set);				      \
    57  		    while (--__cnt >= 0) __set->__val[__cnt] = 0;	      \
    58  		    0; }))
    59  #define __sigfillset(set) \
    60    (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
    61  		    sigset_t *__set = (set);				      \
    62  		    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;	      \
    63  		    0; }))
    64  
    65  #ifdef __USE_GNU
    66  /* The POSIX does not specify for handling the whole signal set in one
    67     command.  This is often wanted and so we define three more functions
    68     here.  */
    69  #define __sigisemptyset(set) \
    70    (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
    71  		    const sigset_t *__set = (set);			      \
    72  		    int __ret = __set->__val[--__cnt];			      \
    73  		    while (!__ret && --__cnt >= 0)			      \
    74  			__ret = __set->__val[__cnt];			      \
    75  		    __ret == 0; }))
    76  #define __sigandset(dest, left, right) \
    77    (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
    78  		    sigset_t *__dest = (dest);				      \
    79  		    const sigset_t *__left = (left);			      \
    80  		    const sigset_t *__right = (right);			      \
    81  		    while (--__cnt >= 0)				      \
    82  		      __dest->__val[__cnt] = (__left->__val[__cnt]	      \
    83  					      & __right->__val[__cnt]);	      \
    84  		    0; }))
    85  #define __sigorset(dest, left, right) \
    86    (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
    87  		    sigset_t *__dest = (dest);				      \
    88  		    const sigset_t *__left = (left);			      \
    89  		    const sigset_t *__right = (right);			      \
    90  		    while (--__cnt >= 0)				      \
    91  		      __dest->__val[__cnt] = (__left->__val[__cnt]	      \
    92  					      | __right->__val[__cnt]);	      \
    93  		    0; }))
    94  #endif
    95  #endif
    96  
    97  /* These functions needn't check for a bogus signal number -- error
    98     checking is done in the non __ versions.  */
    99  
   100  extern int __sigismember(const __sigset_t *, int);
   101  extern int __sigaddset(__sigset_t *, int);
   102  extern int __sigdelset(__sigset_t *, int);
   103  
   104  #ifdef __USE_EXTERN_INLINES
   105  #define __SIGSETFN(NAME, BODY, CONST)					      \
   106    _EXTERN_INLINE int							      \
   107    NAME (CONST __sigset_t *__set, int __sig)				      \
   108    {									      \
   109      unsigned long int __mask = __sigmask (__sig);			      \
   110      unsigned long int __word = __sigword (__sig);			      \
   111      return BODY;							      \
   112    }
   113  
   114  __SIGSETFN(__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, const) __SIGSETFN(__sigaddset, ((__set->__val[__word] |= __mask), 0),) __SIGSETFN(__sigdelset, ((__set->__val[__word] &= ~__mask), 0),)
   115  #undef __SIGSETFN
   116  #endif
   117  #endif				/* ! _SIGSET_H_fns.  */