From 57e8823548ad6e65d33b2153edeb18fb0edc20e6 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Sat, 17 Oct 2009 14:32:36 -0700 Subject: cancellation support for a large amount of the required syscalls Signed-off-by: Austin Foxley --- libc/sysdeps/linux/common/poll.c | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'libc/sysdeps/linux/common/poll.c') diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c index 4a6f06e19..425da3c8a 100644 --- a/libc/sysdeps/linux/common/poll.c +++ b/libc/sysdeps/linux/common/poll.c @@ -20,30 +20,33 @@ #include #include -#ifdef __NR_poll +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +#include +#else +#define SINGLE_THREAD_P 1 +#endif + +libc_hidden_proto(poll) -_syscall3(int, poll, struct pollfd *, fds, - unsigned long int, nfds, int, timeout) +#ifdef __NR_poll -#elif defined(__NR_ppoll) && defined __UCLIBC_LINUX_SPECIFIC__ +#define __NR___syscall_poll __NR_poll +static inline _syscall3(int, __syscall_poll, struct pollfd *, fds, + unsigned long int, nfds, int, timeout); int poll(struct pollfd *fds, nfds_t nfds, int timeout) { - struct timespec *ts = NULL, tval; - if (timeout > 0) { - tval.tv_sec = timeout / 1000; - tval.tv_nsec = (timeout % 1000) * 1000000; - ts = &tval; - } else if (timeout == 0) { - tval.tv_sec = 0; - tval.tv_nsec = 0; - ts = &tval; - } - return ppoll(fds, nfds, ts, NULL); + if (SINGLE_THREAD_P) + return __syscall_poll(fds, nfds, timeout); + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ + int oldtype = LIBC_CANCEL_ASYNC (); + int result = __syscall_poll(fds, nfds, timeout); + LIBC_CANCEL_RESET (oldtype); + return result; +#endif } - -#else -/* ugh, this arch lacks poll, so we need to emulate this crap ... */ +#else /* !__NR_poll */ #include #include @@ -53,6 +56,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) #include #include +libc_hidden_proto(getdtablesize) +libc_hidden_proto(select) + /* uClinux 2.0 doesn't have poll, emulate it using select */ /* Poll the file descriptors described by the NFDS structures starting at @@ -220,10 +226,4 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) } #endif - -#ifndef __LINUXTHREADS_OLD__ libc_hidden_def(poll) -#else -libc_hidden_weak(poll) -strong_alias(poll,__libc_poll) -#endif -- cgit v1.2.3