summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/poll.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-02-28 22:25:41 +0000
committerMike Frysinger <vapier@gentoo.org>2007-02-28 22:25:41 +0000
commit148c1f77492a22ddfc87375c3b2464d5521a3843 (patch)
tree36c8a9c57a6e4e8a0760215f572a6ed39d6d2cae /libc/sysdeps/linux/common/poll.c
parent0306ff3482fa7c597c9e7bf9dc961a11983c48ef (diff)
add support for ppoll() and emulate poll() with it when __NR_poll does not exist
Diffstat (limited to 'libc/sysdeps/linux/common/poll.c')
-rw-r--r--libc/sysdeps/linux/common/poll.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index 2d6da24b8..a8366cd27 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -23,10 +23,27 @@
extern __typeof(poll) __libc_poll;
#ifdef __NR_poll
+
# define __NR___libc_poll __NR_poll
_syscall3(int, __libc_poll, struct pollfd *, fds,
unsigned long int, nfds, int, timeout);
+
+#elif defined(__NR_ppoll)
+
+libc_hidden_proto(ppoll)
+int __libc_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) *1000;
+ ts = &tval;
+ }
+ return ppoll(fds, nfds, ts, NULL);
+}
+
#else
+/* ugh, this arch lacks poll, so we need to emulate this crap ... */
#include <alloca.h>
#include <sys/types.h>