sigprocmask.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * sigprocmask() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #if defined __USE_POSIX
  10. #include <signal.h>
  11. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  12. # include <pthreadP.h> /* SIGCANCEL */
  13. #endif
  14. #undef sigprocmask
  15. libc_hidden_proto(sigprocmask)
  16. #ifdef __NR_rt_sigprocmask
  17. # define __NR___rt_sigprocmask __NR_rt_sigprocmask
  18. static __always_inline
  19. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  20. sigset_t *, oldset, size_t, size)
  21. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  22. {
  23. #ifdef SIGCANCEL
  24. sigset_t local_newmask;
  25. /*
  26. * The only thing we have to make sure here is that SIGCANCEL and
  27. * SIGSETXID are not blocked.
  28. */
  29. if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
  30. # ifdef SIGSETXID
  31. || unlikely (__sigismember (set, SIGSETXID))
  32. # endif
  33. ))
  34. {
  35. local_newmask = *set;
  36. __sigdelset (&local_newmask, SIGCANCEL);
  37. # ifdef SIGSETXID
  38. __sigdelset (&local_newmask, SIGSETXID);
  39. # endif
  40. set = &local_newmask;
  41. }
  42. #endif
  43. return __rt_sigprocmask(how, set, oldset, __SYSCALL_SIGSET_T_SIZE);
  44. }
  45. #else
  46. # define __NR___syscall_sigprocmask __NR_sigprocmask
  47. static __always_inline
  48. _syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
  49. sigset_t *, oldset)
  50. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  51. {
  52. #ifdef SIGCANCEL
  53. sigset_t local_newmask;
  54. /*
  55. * The only thing we have to make sure here is that SIGCANCEL and
  56. * SIGSETXID are not blocked.
  57. */
  58. if (set != NULL && (unlikely (__sigismember (set, SIGCANCEL))
  59. # ifdef SIGSETXID
  60. || unlikely (__sigismember (set, SIGSETXID))
  61. # endif
  62. ))
  63. {
  64. local_newmask = *set;
  65. __sigdelset (&local_newmask, SIGCANCEL);
  66. # ifdef SIGSETXID
  67. __sigdelset (&local_newmask, SIGSETXID);
  68. # endif
  69. set = &local_newmask;
  70. }
  71. #endif
  72. return (__syscall_sigprocmask(how, set, oldset));
  73. }
  74. #endif
  75. libc_hidden_def(sigprocmask)
  76. #endif