sigprocmask.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #undef sigprocmask
  13. libc_hidden_proto(sigprocmask)
  14. #ifdef __NR_rt_sigprocmask
  15. # define __NR___rt_sigprocmask __NR_rt_sigprocmask
  16. static __always_inline
  17. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  18. sigset_t *, oldset, size_t, size)
  19. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  20. {
  21. #ifdef SIGCANCEL
  22. sigset_t local_newmask;
  23. /*
  24. * The only thing we have to make sure here is that SIGCANCEL and
  25. * SIGSETXID are not blocked.
  26. */
  27. if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
  28. # ifdef SIGSETXID
  29. || __builtin_expect (__sigismember (set, SIGSETXID), 0)
  30. # endif
  31. ))
  32. {
  33. local_newmask = *set;
  34. __sigdelset (&local_newmask, SIGCANCEL);
  35. # ifdef SIGSETXID
  36. __sigdelset (&local_newmask, SIGSETXID);
  37. # endif
  38. set = &local_newmask;
  39. }
  40. #endif
  41. return __rt_sigprocmask(how, set, oldset, _NSIG / 8);
  42. }
  43. #else
  44. # define __NR___syscall_sigprocmask __NR_sigprocmask
  45. static __always_inline
  46. _syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
  47. sigset_t *, oldset)
  48. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  49. {
  50. #ifdef SIGCANCEL
  51. sigset_t local_newmask;
  52. /*
  53. * The only thing we have to make sure here is that SIGCANCEL and
  54. * SIGSETXID are not blocked.
  55. */
  56. if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
  57. # ifdef SIGSETXID
  58. || __builtin_expect (__sigismember (set, SIGSETXID), 0)
  59. # endif
  60. ))
  61. {
  62. local_newmask = *set;
  63. __sigdelset (&local_newmask, SIGCANCEL);
  64. # ifdef SIGSETXID
  65. __sigdelset (&local_newmask, SIGSETXID);
  66. # endif
  67. set = &local_newmask;
  68. }
  69. #endif
  70. return (__syscall_sigprocmask(how, set, oldset));
  71. }
  72. #endif
  73. libc_hidden_def(sigprocmask)
  74. #endif