[prev in list] [next in list] [prev in thread] [next in thread]
List: musl
Subject: [musl] [PATCH 12/18] poll, ppoll: prefer time64 variant of ppoll if available
From: Alexander Lobakin <alobakin () pm ! me>
Date: 2020-12-27 18:42:08
Message-ID: 20201227184032.22413-12-alobakin () pm ! me
[Download RAW message or body]
Instead of using time64 variant "only when needed", use it as
a default and fallback to time32 only on -ENOSYS.
Also use ppoll as a default for poll and fallback to poll only
at last.
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
src/linux/ppoll.c | 8 +++-----
src/select/poll.c | 23 ++++++++++++++++++-----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/linux/ppoll.c b/src/linux/ppoll.c
index e614600ab8b7..88a5b91a47b5 100644
--- a/src/linux/ppoll.c
+++ b/src/linux/ppoll.c
@@ -12,11 +12,9 @@ int ppoll(struct pollfd *fds, nfds_t n, const struct timespec *to, const sigset_
time_t s = to ? to->tv_sec : 0;
long ns = to ? to->tv_nsec : 0;
#ifdef SYS_ppoll_time64
- int r = -ENOSYS;
- if (SYS_ppoll == SYS_ppoll_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_ppoll_time64, fds, n,
- to ? ((long long[]){s, ns}) : 0,
- mask, _NSIG/8);
+ int r = __syscall_cp(SYS_ppoll_time64, fds, n,
+ to ? ((long long[]){s, ns}) : 0,
+ mask, _NSIG/8);
if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS)
return __syscall_ret(r);
s = CLAMP(s);
diff --git a/src/select/poll.c b/src/select/poll.c
index c84c8a999ccc..e6b737081939 100644
--- a/src/select/poll.c
+++ b/src/select/poll.c
@@ -5,11 +5,24 @@
int poll(struct pollfd *fds, nfds_t n, int timeout)
{
+ time_t s = timeout >= 0 ? timeout / 1000 : 0;
+ long ns = timeout >= 0 ? timeout % 1000 * 1000000 : 0;
+ int r = -ENOSYS;
+#ifdef SYS_ppoll_time64
+ int r = __syscall_cp(SYS_ppoll_time64, fds, n,
+ timeout >= 0 ? ((long long[]){s, ns}) : 0,
+ 0, _NSIG / 8);
+ if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS)
+ return __syscall_ret(r);
+#endif
+#ifdef SYS_ppoll
+ r = __syscall_cp(SYS_ppoll, fds, n,
+ timeout >= 0 ? ((long[]){s, ns}) : 0,
+ 0, _NSIG / 8);
+#endif
#ifdef SYS_poll
- return syscall_cp(SYS_poll, fds, n, timeout);
-#else
- return syscall_cp(SYS_ppoll, fds, n, timeout>=0 ?
- &((struct timespec){ .tv_sec = timeout/1000,
- .tv_nsec = timeout%1000*1000000 }) : 0, 0, _NSIG/8);
+ if (r == -ENOSYS)
+ r = __syscall_cp(SYS_poll, fds, n, timeout);
#endif
+ return __syscall_ret(r);
}
--
2.29.2
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic