summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/poll.c
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2009-10-17 14:32:36 -0700
committerAustin Foxley <austinf@cetoncorp.com>2009-10-17 14:32:36 -0700
commit57e8823548ad6e65d33b2153edeb18fb0edc20e6 (patch)
tree8cfc6fea89ec4e90c94b5764233ee2b2ed9cc54d /libc/sysdeps/linux/common/poll.c
parent9a737ab7a40984cfdfffd014562a220a3736a10f (diff)
cancellation support for a large amount of the required syscalls
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libc/sysdeps/linux/common/poll.c')
-rw-r--r--libc/sysdeps/linux/common/poll.c48
1 files changed, 24 insertions, 24 deletions
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 <sys/syscall.h>
#include <sys/poll.h>
-#ifdef __NR_poll
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#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 <alloca.h>
#include <sys/types.h>
@@ -53,6 +56,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
#include <sys/param.h>
#include <unistd.h>
+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