sigsetops.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* __sigset_t manipulators. Generic/BSD version.
  2. Copyright (C) 1991-2019 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, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _SIGSETOPS_H
  16. #define _SIGSETOPS_H 1
  17. #include <signal.h>
  18. /* Return a mask that includes SIG only. The cast to `sigset_t' avoids
  19. overflow if `sigset_t' is wider than `int'. */
  20. # define __sigmask(sig) (((__sigset_t) 1) << ((sig) - 1))
  21. #define __sigemptyset(set) \
  22. (__extension__ ({ \
  23. *(set) = (__sigset_t) 0; \
  24. 0; \
  25. }))
  26. #define __sigfillset(set) \
  27. (__extension__ ({ \
  28. *(set) = ~(__sigset_t) 0; \
  29. 0; \
  30. }))
  31. # define __sigisemptyset(set) \
  32. (*(set) == (__sigset_t) 0)
  33. # define __sigandset(dest, left, right) \
  34. (__extension__ ({ \
  35. *(dest) = *(left) & *(right); \
  36. 0; \
  37. }))
  38. # define __sigorset(dest, left, right) \
  39. (__extension__ ({ \
  40. *(dest) = *(left) | *(right); \
  41. 0; \
  42. }))
  43. /* These macros needn't check for a bogus signal number;
  44. checking is done in the non-__ versions. */
  45. # define __sigismember(set, sig) \
  46. (__extension__ ({ \
  47. __sigset_t __mask = __sigmask (sig); \
  48. *(set) & __mask ? 1 : 0; \
  49. }))
  50. # define __sigaddset(set, sig) \
  51. (__extension__ ({ \
  52. __sigset_t __mask = __sigmask (sig); \
  53. *(set) |= __mask; \
  54. 0; \
  55. }))
  56. # define __sigdelset(set, sig) \
  57. (__extension__ ({ \
  58. __sigset_t __mask = __sigmask (sig); \
  59. *(set) &= ~__mask; \
  60. 0; \
  61. }))
  62. #endif