sigsuspend.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #if defined __USE_POSIX
  11. #include <signal.h>
  12. #undef sigsuspend
  13. libc_hidden_proto(sigsuspend)
  14. #ifdef __NR_rt_sigsuspend
  15. # define __NR___rt_sigsuspend __NR_rt_sigsuspend
  16. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  17. # include <errno.h>
  18. # include <sysdep-cancel.h>
  19. /* Change the set of blocked signals to SET,
  20. wait until a signal arrives, and restore the set of blocked signals. */
  21. int sigsuspend (const sigset_t *set)
  22. {
  23. if (SINGLE_THREAD_P)
  24. return INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
  25. int oldtype = LIBC_CANCEL_ASYNC ();
  26. int result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
  27. LIBC_CANCEL_RESET (oldtype);
  28. return result;
  29. }
  30. # else
  31. static inline _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  32. int sigsuspend(const sigset_t * mask)
  33. {
  34. return __rt_sigsuspend(mask, _NSIG / 8);
  35. }
  36. # endif
  37. #else
  38. # define __NR___syscall_sigsuspend __NR_sigsuspend
  39. static __inline__ _syscall3(int, __syscall_sigsuspend, int, a, unsigned long int, b,
  40. unsigned long int, c)
  41. int sigsuspend(const sigset_t * set)
  42. {
  43. return __syscall_sigsuspend(0, 0, set->__val[0]);
  44. }
  45. #endif
  46. libc_hidden_def(sigsuspend)
  47. #endif