sigprocmask.c 2.0 KB

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