summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
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
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')
-rw-r--r--libc/sysdeps/linux/common/poll.c36
-rw-r--r--libc/sysdeps/linux/common/ppoll.c38
2 files changed, 27 insertions, 47 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)
diff --git a/libc/sysdeps/linux/common/ppoll.c b/libc/sysdeps/linux/common/ppoll.c
index 3ca3f7333..9135fe523 100644
--- a/libc/sysdeps/linux/common/ppoll.c
+++ b/libc/sysdeps/linux/common/ppoll.c
@@ -20,19 +20,16 @@
#include <sys/syscall.h>
#if defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
-# define __need_NULL
-# include <stddef.h>
-# include <signal.h>
-# include <sys/poll.h>
-# ifdef __UCLIBC_HAS_THREADS_NATIVE__
-# include <sysdep-cancel.h>
-# else
-# define SINGLE_THREAD_P 1
-# endif
-
-int
-ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
- const sigset_t *sigmask)
+
+#define __need_NULL
+#include <stddef.h>
+#include <signal.h>
+#include <sys/poll.h>
+#include <cancel.h>
+
+static int
+__NC(ppoll)(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+ const sigset_t *sigmask)
{
/* The Linux kernel can in some situations update the timeout value.
We do not want that so use a local variable. */
@@ -41,14 +38,11 @@ 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);
-
-# 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
+ return INLINE_SYSCALL(ppoll, 5, fds, nfds, timeout, sigmask, __SYSCALL_SIGSET_T_SIZE);
}
+
+CANCELLABLE_SYSCALL(int, ppoll, (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+ const sigset_t *sigmask),
+ (fds, nfds, timeout, sigmask))
+
#endif