mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexander Lobakin <alobakin@pm.me>
To: Rich Felker <dalias@aerifal.cx>, musl@lists.openwall.com
Cc: Alexander Lobakin <alobakin@pm.me>
Subject: [musl] [PATCH 11/18] pselect, select: prefer time64 variant of pselect6 if available
Date: Sun, 27 Dec 2020 18:42:01 +0000	[thread overview]
Message-ID: <20201227184032.22413-11-alobakin@pm.me> (raw)
In-Reply-To: <20201227184032.22413-1-alobakin@pm.me>

Instead of using time64 variant "only when needed", use it as
a default and fallback to time32 only on -ENOSYS.
Also use deprecated select only as a last chance.

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 src/select/pselect.c |  6 ++----
 src/select/select.c  | 22 ++++++++++++----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/select/pselect.c b/src/select/pselect.c
index 54cfb291bba2..f68616a247de 100644
--- a/src/select/pselect.c
+++ b/src/select/pselect.c
@@ -13,10 +13,8 @@ int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restric
 	time_t s = ts ? ts->tv_sec : 0;
 	long ns = ts ? ts->tv_nsec : 0;
 #ifdef SYS_pselect6_time64
-	int r = -ENOSYS;
-	if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
-		r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
-			ts ? ((long long[]){s, ns}) : 0, data);
+	int r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
+		ts ? ((long long[]){s, ns}) : 0, data);
 	if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
 		return __syscall_ret(r);
 	s = CLAMP(s);
diff --git a/src/select/select.c b/src/select/select.c
index 8a7868840304..d2dbb7b08362 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -13,6 +13,7 @@ int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict
 	suseconds_t us = tv ? tv->tv_usec : 0;
 	long ns;
 	const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1;
+	int r = -ENOSYS;
 
 	if (s<0 || us<0) return __syscall_ret(-EINVAL);
 	if (us/1000000 > max_time - s) {
@@ -26,19 +27,20 @@ int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict
 	}
 
 #ifdef SYS_pselect6_time64
-	int r = -ENOSYS;
-	if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
-		r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
-			tv ? ((long long[]){s, ns}) : 0,
-			((syscall_arg_t[]){ 0, _NSIG/8 }));
+	r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
+		tv ? ((long long[]){s, ns}) : 0,
+		((syscall_arg_t[]){ 0, _NSIG/8 }));
 	if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
 		return __syscall_ret(r);
 #endif
-#ifdef SYS_select
-	return syscall_cp(SYS_select, n, rfds, wfds, efds,
-		tv ? ((long[]){s, us}) : 0);
-#else
-	return syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
+#ifdef SYS_pselect6
+	r = __syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
 		tv ? ((long[]){s, ns}) : 0, ((syscall_arg_t[]){ 0, _NSIG/8 }));
 #endif
+#ifdef SYS_select
+	if (r == -ENOSYS)
+		r = __syscall_cp(SYS_select, n, rfds, wfds, efds,
+			tv ? ((long[]){s, us}) : 0);
+#endif
+	return __syscall_ret(r);
 }
-- 
2.29.2



  parent reply	other threads:[~2020-12-27 18:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 18:39 [musl] [PATCH 00/18] time64: always prefer time64 syscalls Alexander Lobakin
2020-12-27 18:40 ` [musl] [PATCH 01/18] clock_gettime: prefer time64 variant if available Alexander Lobakin
2020-12-27 18:40   ` [musl] [PATCH 02/18] clock_settime: " Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 03/18] clock_adjtime: try adjtimex at last Alexander Lobakin
2020-12-27 21:57     ` Rich Felker
2020-12-27 18:41   ` [musl] [PATCH 04/18] clock_getres: use time64 variant by default Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 05/18] clock_nanosleep: prefer time64 variant if available Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 06/18] timer_gettime: " Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 07/18] timer_settime: " Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 08/18] timerfd_gettime: " Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 09/18] timerfd_settime: " Alexander Lobakin
2020-12-27 18:41   ` [musl] [PATCH 10/18] utimensat: " Alexander Lobakin
2020-12-27 18:42   ` Alexander Lobakin [this message]
2020-12-27 18:42   ` [musl] [PATCH 12/18] poll, ppoll: prefer time64 variant of ppoll " Alexander Lobakin
2020-12-27 18:42   ` [musl] [PATCH 13/18] mq_timedsend: prefer time64 variant " Alexander Lobakin
2020-12-27 18:42   ` [musl] [PATCH 14/18] mq_timedreceive: " Alexander Lobakin
2020-12-27 18:42   ` [musl] [PATCH 15/18] semtimedop: prefer time64 variant of semtimedop " Alexander Lobakin
2020-12-27 18:42   ` [musl] [PATCH 16/18] [rt_]sigtimedwait: prefer time64 variant " Alexander Lobakin
2020-12-27 18:42   ` [musl] [PATCH 17/18] futex: " Alexander Lobakin
2020-12-27 22:18     ` Rich Felker
2020-12-27 18:42   ` [musl] [PATCH 18/18] sched_rr_get_interval: use " Alexander Lobakin
2020-12-27 21:54   ` [musl] [PATCH 01/18] clock_gettime: prefer " Rich Felker
2020-12-27 21:52 ` [musl] [PATCH 00/18] time64: always prefer time64 syscalls Rich Felker
2020-12-28 11:11 ` Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201227184032.22413-11-alobakin@pm.me \
    --to=alobakin@pm.me \
    --cc=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).