summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/poll.c
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-04-22 00:42:58 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:41 +0200
commit145ad1d976abff15f32e129e25f47c04807d24ac (patch)
tree46a8d5a463865e48f570833285ef28726c256b22 /libc/sysdeps/linux/common/poll.c
parentb72b0b14d0da0b506fbddf755cc8c7d0cd813287 (diff)
poll, ppoll: use cancel.h
use __SYSCALL_SIGSET_T_SIZE use non-cancellable select in fallback Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/poll.c')
-rw-r--r--libc/sysdeps/linux/common/poll.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index 92c90da66..891d2fba4 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -20,31 +20,14 @@
#include <sys/syscall.h>
#include <sys/poll.h>
#include <bits/kernel-features.h>
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <sysdep-cancel.h>
-#else
-#define SINGLE_THREAD_P 1
-#endif
+#include <cancel.h>
#if defined __ASSUME_POLL_SYSCALL && defined __NR_poll
-#define __NR___syscall_poll __NR_poll
-static _syscall3(int, __syscall_poll, struct pollfd *, fds,
- unsigned long int, nfds, int, timeout);
+#define __NR___poll_nocancel __NR_poll
+static _syscall3(int, __NC(poll), struct pollfd *, fds,
+ unsigned long int, nfds, int, timeout)
-int poll(struct pollfd *fds, nfds_t nfds, int timeout)
-{
- 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 /* !__NR_poll */
#include <alloca.h>
@@ -54,6 +37,7 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
#include <sys/time.h>
#include <sys/param.h>
#include <unistd.h>
+#include <sys/select.h>
/* uClinux 2.0 doesn't have poll, emulate it using select */
@@ -63,7 +47,7 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
Returns the number of file descriptors with events, zero if timed out,
or -1 for errors. */
-int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+int __NC(poll)(struct pollfd *fds, nfds_t nfds, int timeout)
{
static int max_fd_size;
struct timeval tv;
@@ -134,7 +118,7 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
while (1)
{
- ready = select (maxfd + 1, rset, wset, xset,
+ ready = __NC(select) (maxfd + 1, rset, wset, xset,
timeout == -1 ? NULL : &tv);
/* It might be that one or more of the file descriptors is invalid.
@@ -177,7 +161,7 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
if (f->events & POLLPRI)
FD_SET (f->fd, sngl_xset);
- n = select (f->fd + 1, sngl_rset, sngl_wset, sngl_xset,
+ n = __NC(select) (f->fd + 1, sngl_rset, sngl_wset, sngl_xset,
&sngl_tv);
if (n != -1)
{
@@ -222,4 +206,6 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
}
#endif
-libc_hidden_def(poll)
+CANCELLABLE_SYSCALL(int, poll, (struct pollfd *fds, nfds_t nfds, int timeout),
+ (fds, nfds, timeout))
+lt_libc_hidden(poll)