From 4b88e6e858b55def2ef0392278ddf81835f2ac45 Mon Sep 17 00:00:00 2001 From: Salvatore Cro Date: Thu, 9 Sep 2010 16:01:04 +0200 Subject: libc: Fix cancellation handling in some C functions According to POSIX.1-2008 standard, the following syscalls shall be cancellation points : waitid, sleep, fdatasync, ppoll. Further, if generic syscall is not available and stubs are configured, provide the stub implementation for function. Signed-off-by: Salvatore Cro Signed-off-by: Carmelo Amoroso --- libc/sysdeps/linux/common/ppoll.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libc/sysdeps/linux/common/ppoll.c') diff --git a/libc/sysdeps/linux/common/ppoll.c b/libc/sysdeps/linux/common/ppoll.c index 02c8013a5..09b2b1539 100644 --- a/libc/sysdeps/linux/common/ppoll.c +++ b/libc/sysdeps/linux/common/ppoll.c @@ -24,6 +24,12 @@ #include #if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__ +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include +# else +# define SINGLE_THREAD_P 1 +# endif + int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) @@ -35,8 +41,15 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, tval = *timeout; timeout = &tval; } + if (SINGLE_THREAD_P) + return INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, _NSIG / 8); - return INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, _NSIG / 8); +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, _NSIG / 8); + LIBC_CANCEL_RESET (oldtype); + return result; +# endif } libc_hidden_def(ppoll) #endif -- cgit v1.2.3