sigprocmask.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifdef __NR_rt_sigprocmask
  14. # define __NR___rt_sigprocmask __NR_rt_sigprocmask
  15. static __always_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 __always_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)
  61. #endif