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