sigsuspend.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * sigsuspend() 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. #ifdef __USE_POSIX
  11. #include <signal.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. # ifndef __NR_rt_sigsuspend
  14. # error break build, NPTL needs rt_sigsuspend syscall
  15. # endif
  16. # include <sysdep-cancel.h>
  17. #else
  18. # define SINGLE_THREAD_P 1
  19. #endif
  20. #ifdef __NR_rt_sigsuspend
  21. static _syscall2(int, rt_sigsuspend, const sigset_t *, set, size_t, size)
  22. /* Change the set of blocked signals to SET,
  23. wait until a signal arrives, and restore the set of blocked signals. */
  24. int sigsuspend(const sigset_t *set)
  25. {
  26. if (SINGLE_THREAD_P)
  27. return rt_sigsuspend(set, _NSIG / 8);
  28. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  29. int oldtype = LIBC_CANCEL_ASYNC ();
  30. int result = rt_sigsuspend(set, _NSIG / 8);
  31. LIBC_CANCEL_RESET (oldtype);
  32. return result;
  33. # endif
  34. }
  35. #else
  36. # define __NR___syscall_sigsuspend __NR_sigsuspend
  37. static __always_inline _syscall3(int, __syscall_sigsuspend, int, a, unsigned long int, b,
  38. unsigned long int, c)
  39. int sigsuspend(const sigset_t *set)
  40. {
  41. return __syscall_sigsuspend(0, 0, set->__val[0]);
  42. }
  43. #endif
  44. libc_hidden_def(sigsuspend)
  45. #endif