sigset.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:5k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* __sig_atomic_t, __sigset_t, and related definitions.  Linux version.
  2.    Copyright (C) 1991, 1992, 1994, 1996, 1997 Free Software Foundation, Inc.
  3.    This file is part of the GNU C Library.
  4.    The GNU C Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Lesser General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2.1 of the License, or (at your option) any later version.
  8.    The GNU C Library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Lesser General Public License for more details.
  12.    You should have received a copy of the GNU Lesser General Public
  13.    License along with the GNU C Library; if not, write to the Free
  14.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15.    02111-1307 USA.  */
  16. #ifndef _SIGSET_H_types
  17. # define _SIGSET_H_types 1
  18. typedef int __sig_atomic_t;
  19. /* A `sigset_t' has a bit for each signal.  */
  20. # define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))
  21. typedef struct
  22.   {
  23.     unsigned long int __val[_SIGSET_NWORDS];
  24.   } __sigset_t;
  25. #endif
  26. /* We only want to define these functions if <signal.h> was actually
  27.    included; otherwise we were included just to define the types.  Since we
  28.    are namespace-clean, it wouldn't hurt to define extra macros.  But
  29.    trouble can be caused by functions being defined (e.g., any global
  30.    register vars declared later will cause compilation errors).  */
  31. #if !defined _SIGSET_H_fns && defined _SIGNAL_H
  32. # define _SIGSET_H_fns 1
  33. # ifndef _EXTERN_INLINE
  34. #  define _EXTERN_INLINE extern __inline
  35. # endif
  36. /* Return a mask that includes the bit for SIG only.  */
  37. # define __sigmask(sig) 
  38.   (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
  39. /* Return the word index for SIG.  */
  40. # define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int)))
  41. # if defined __GNUC__ && __GNUC__ >= 2
  42. #  define __sigemptyset(set) 
  43.   (__extension__ ({ int __cnt = _SIGSET_NWORDS;       
  44.     sigset_t *__set = (set);       
  45.     while (--__cnt >= 0) __set->__val[__cnt] = 0;       
  46.     0; }))
  47. #  define __sigfillset(set) 
  48.   (__extension__ ({ int __cnt = _SIGSET_NWORDS;       
  49.     sigset_t *__set = (set);       
  50.     while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;       
  51.     0; }))
  52. #  ifdef __USE_GNU
  53. /* The POSIX does not specify for handling the whole signal set in one
  54.    command.  This is often wanted and so we define three more functions
  55.    here.  */
  56. #   define __sigisemptyset(set) 
  57.   (__extension__ ({ int __cnt = _SIGSET_NWORDS;       
  58.     const sigset_t *__set = (set);       
  59.     int __ret = __set->__val[--__cnt];       
  60.     while (!__ret && --__cnt >= 0)       
  61. __ret = __set->__val[__cnt];       
  62.     __ret == 0; }))
  63. #   define __sigandset(dest, left, right) 
  64.   (__extension__ ({ int __cnt = _SIGSET_NWORDS;       
  65.     sigset_t *__dest = (dest);       
  66.     const sigset_t *__left = (left);       
  67.     const sigset_t *__right = (right);       
  68.     while (--__cnt >= 0)       
  69.       __dest->__val[__cnt] = (__left->__val[__cnt]       
  70.       & __right->__val[__cnt]);       
  71.     0; }))
  72. #   define __sigorset(dest, left, right) 
  73.   (__extension__ ({ int __cnt = _SIGSET_NWORDS;       
  74.     sigset_t *__dest = (dest);       
  75.     const sigset_t *__left = (left);       
  76.     const sigset_t *__right = (right);       
  77.     while (--__cnt >= 0)       
  78.       __dest->__val[__cnt] = (__left->__val[__cnt]       
  79.       | __right->__val[__cnt]);       
  80.     0; }))
  81. #  endif
  82. # endif
  83. /* These functions needn't check for a bogus signal number -- error
  84.    checking is done in the non __ versions.  */
  85. extern int __sigismember (__const __sigset_t *, int);
  86. extern int __sigaddset (__sigset_t *, int);
  87. extern int __sigdelset (__sigset_t *, int);
  88. # ifdef __USE_EXTERN_INLINES
  89. #  define __SIGSETFN(NAME, BODY, CONST)       
  90.   _EXTERN_INLINE int       
  91.   NAME (CONST __sigset_t *__set, int __sig)       
  92.   {       
  93.     unsigned long int __mask = __sigmask (__sig);       
  94.     unsigned long int __word = __sigword (__sig);       
  95.     return BODY;       
  96.   }
  97. __SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const)
  98. __SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), )
  99. __SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), )
  100. #  undef __SIGSETFN
  101. # endif
  102. #endif /* ! _SIGSET_H_fns.  */