sigset.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef __SIGSET_H__
  2. #define __SIGSET_H__
  3. /* __sig_atomic_t, __sigset_t, and related definitions. Linux version.
  4. Copyright (C) 1991, 1992, 1994, 1996, 1997, 2007
  5. Free Software Foundation, Inc.
  6. This file is part of the GNU C Library.
  7. The GNU C Library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Lesser General Public
  9. License as published by the Free Software Foundation; either
  10. version 2.1 of the License, or (at your option) any later version.
  11. The GNU C Library is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. 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, write to the Free
  17. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18. 02111-1307 USA. */
  19. #define _SIGSET_H_types 1
  20. #define _SIGSET_H_fns 1
  21. #define ____sigset_t_defined
  22. typedef int __sig_atomic_t;
  23. /* A `sigset_t' has a bit for each signal. */
  24. # define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long int)))
  25. typedef struct
  26. {
  27. unsigned long int __val[_SIGSET_NWORDS];
  28. } __sigset_t;
  29. /* Return a mask that includes the bit for SIG only. */
  30. # define __sigmask(sig) \
  31. (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
  32. /* Return the word index for SIG. */
  33. # define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int)))
  34. # define __sigemptyset(set) \
  35. ({ int __cnt = _SIGSET_NWORDS; \
  36. __sigset_t *__set = (set); \
  37. while (--__cnt >= 0) __set->__val[__cnt] = 0; \
  38. 0; })
  39. # define __sigfillset(set) \
  40. ({ int __cnt = _SIGSET_NWORDS; \
  41. __sigset_t *__set = (set); \
  42. while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \
  43. 0; })
  44. # define __sigcopyset(set, src) \
  45. ({ int __cnt = _SIGSET_NWORDS; \
  46. __sigset_t *__set = (set); \
  47. __sigset_t *__src = (src); \
  48. while (--__cnt >= 0) __set->__val[__cnt] = __src->__val[__cnt]; \
  49. 0; })
  50. /* These functions needn't check for a bogus signal number -- error
  51. checking is done in the non __ versions. */
  52. # define __SIGSETFN(NAME, BODY, CONST) \
  53. static inline int \
  54. NAME (CONST __sigset_t *__set, int __sig) \
  55. { \
  56. unsigned long int __mask = __sigmask (__sig); \
  57. unsigned long int __word = __sigword (__sig); \
  58. return BODY; \
  59. }
  60. __SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const)
  61. __SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), )
  62. __SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), )
  63. # undef __SIGSETFN
  64. #endif /* __SIGSET_H__ */