sigprocmask.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. if (set &&
  22. # if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
  23. (((unsigned int) how) > 2)
  24. # elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
  25. (((unsigned int)(how-1)) > 2)
  26. # else
  27. # warning "compile time assumption violated.. slow path..."
  28. ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
  29. && (how != SIG_SETMASK))
  30. # endif
  31. ) {
  32. __set_errno(EINVAL);
  33. return -1;
  34. }
  35. return __rt_sigprocmask(how, set, oldset, _NSIG / 8);
  36. }
  37. #else
  38. # define __NR___syscall_sigprocmask __NR_sigprocmask
  39. static __always_inline
  40. _syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
  41. sigset_t *, oldset)
  42. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  43. {
  44. if (set &&
  45. # if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
  46. (((unsigned int) how) > 2)
  47. # elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
  48. (((unsigned int)(how-1)) > 2)
  49. # else
  50. # warning "compile time assumption violated.. slow path..."
  51. ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
  52. && (how != SIG_SETMASK))
  53. # endif
  54. ) {
  55. __set_errno(EINVAL);
  56. return -1;
  57. }
  58. return (__syscall_sigprocmask(how, set, oldset));
  59. }
  60. #endif
  61. libc_hidden_def(sigprocmask)
  62. #endif