sigprocmask.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include <signal.h>
  11. #undef sigprocmask
  12. libc_hidden_proto(sigprocmask)
  13. #ifdef __NR_rt_sigprocmask
  14. # define __NR___rt_sigprocmask __NR_rt_sigprocmask
  15. static inline
  16. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  17. sigset_t *, oldset, size_t, size);
  18. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  19. {
  20. if (set &&
  21. # if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
  22. (((unsigned int) how) > 2)
  23. #elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
  24. (((unsigned int)(how-1)) > 2)
  25. # else
  26. # warning "compile time assumption violated.. slow path..."
  27. ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
  28. && (how != SIG_SETMASK))
  29. # endif
  30. ) {
  31. __set_errno(EINVAL);
  32. return -1;
  33. }
  34. return __rt_sigprocmask(how, set, oldset, _NSIG / 8);
  35. }
  36. #else
  37. # define __NR___syscall_sigprocmask __NR_sigprocmask
  38. static inline
  39. _syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
  40. sigset_t *, oldset);
  41. int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
  42. {
  43. if (set &&
  44. # if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
  45. (((unsigned int) how) > 2)
  46. #elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3)
  47. (((unsigned int)(how-1)) > 2)
  48. # else
  49. # warning "compile time assumption violated.. slow path..."
  50. ((how != SIG_BLOCK) && (how != SIG_UNBLOCK)
  51. && (how != SIG_SETMASK))
  52. # endif
  53. ) {
  54. __set_errno(EINVAL);
  55. return -1;
  56. }
  57. return (__syscall_sigprocmask(how, set, oldset));
  58. }
  59. #endif
  60. libc_hidden_def(sigprocmask)