linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: w@1wt.eu
Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
	thomas@t-8ch.de, "Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH v2 09/13] tools/nolibc: sys_select: add pure 64bit select
Date: Tue, 30 May 2023 03:57:23 +0800	[thread overview]
Message-ID: <fa047211708451779ddbfabeff749c4d692031ff.1685387484.git.falcon@tinylab.org> (raw)
In-Reply-To: <cover.1685387484.git.falcon@tinylab.org>

It's time to provide 64bit time structs for all platforms, for y2038 is
near.

pselect6_time64 has been added from v4.20 and the last arch support is
at least from v5.0.0.

Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/linux-riscv/76a5f9a0-eec4-415a-9c5d-ac3bca4d4b0e@t-8ch.de/
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/linux-riscv/bf3e07c1-75f5-425b-9124-f3f2b230e63a@app.fastmail.com/
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/include/nolibc/arch-aarch64.h   |  3 ---
 tools/include/nolibc/arch-loongarch.h |  3 ---
 tools/include/nolibc/arch-riscv.h     |  3 ---
 tools/include/nolibc/sys.h            | 25 ++++++++++---------------
 4 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h
index 11f294a406b7..53255a3a326f 100644
--- a/tools/include/nolibc/arch-aarch64.h
+++ b/tools/include/nolibc/arch-aarch64.h
@@ -47,10 +47,7 @@ struct sys_stat_struct {
  *   - the arguments are cast to long and assigned into the target registers
  *     which are then simply passed as registers to the asm code, so that we
  *     don't have to experience issues with register constraints.
- *
- * On aarch64, select() is not implemented so we have to use pselect6().
  */
-#define __ARCH_WANT_SYS_PSELECT6
 
 #define my_syscall0(num)                                                      \
 ({                                                                            \
diff --git a/tools/include/nolibc/arch-loongarch.h b/tools/include/nolibc/arch-loongarch.h
index ad3f266e7093..973fdca96651 100644
--- a/tools/include/nolibc/arch-loongarch.h
+++ b/tools/include/nolibc/arch-loongarch.h
@@ -18,10 +18,7 @@
  *   - the arguments are cast to long and assigned into the target
  *     registers which are then simply passed as registers to the asm code,
  *     so that we don't have to experience issues with register constraints.
- *
- * On LoongArch, select() is not implemented so we have to use pselect6().
  */
-#define __ARCH_WANT_SYS_PSELECT6
 
 #define my_syscall0(num)                                                      \
 ({                                                                            \
diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h
index a2e8564e66d6..713eb9d2c91d 100644
--- a/tools/include/nolibc/arch-riscv.h
+++ b/tools/include/nolibc/arch-riscv.h
@@ -53,10 +53,7 @@ struct sys_stat_struct {
  *   - the arguments are cast to long and assigned into the target
  *     registers which are then simply passed as registers to the asm code,
  *     so that we don't have to experience issues with register constraints.
- *
- * On riscv, select() is not implemented so we have to use pselect6().
  */
-#define __ARCH_WANT_SYS_PSELECT6
 
 #define my_syscall0(num)                                                      \
 ({                                                                            \
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 1b3675d4c5fc..db648b5b9a1c 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -1046,28 +1046,23 @@ int sched_yield(void)
 static __attribute__((unused))
 int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
 {
-#if defined(__ARCH_WANT_SYS_OLD_SELECT) && !defined(__NR__newselect)
-	struct sel_arg_struct {
-		unsigned long n;
-		fd_set *r, *w, *e;
-		struct timeval *t;
-	} arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout };
-	return my_syscall1(__NR_select, &arg);
-#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6)
+#if defined(__NR_pselect6) || defined(__NR_pselect6_time64)
+#ifdef __NR_pselect6_time64
+	const long nr_pselect = __NR_pselect6_time64;
+#elif __SIZEOF_LONG__ == 8
+	const long nr_pselect = __NR_pselect6;
+#else
+#error No __NR_pselect6_time64 defined, cannot implement time64 sys_select()
+#endif
 	struct timespec t;
 
 	if (timeout) {
 		t.tv_sec  = timeout->tv_sec;
 		t.tv_nsec = timeout->tv_usec * 1000;
 	}
-	return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
-#elif defined(__NR__newselect) || defined(__NR_select)
-#ifndef __NR__newselect
-#define __NR__newselect __NR_select
-#endif
-	return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
+	return my_syscall6(nr_pselect, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
 #else
-#error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select()
+#error Neither __NR_pselect6 nor __NR_pselect6_time64 defined, cannot implement sys_select()
 #endif
 }
 
-- 
2.25.1


  parent reply	other threads:[~2023-05-29 19:57 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 19:45 [PATCH v2 00/13] nolibc: add part2 of support for rv32 Zhangjin Wu
2023-05-29 19:46 ` [PATCH v2 01/13] selftests/nolibc: remove gettimeofday_bad1/2 completely Zhangjin Wu
2023-05-29 19:47 ` [PATCH v2 02/13] selftests/nolibc: support two errnos with EXPECT_SYSER2() Zhangjin Wu
2023-05-29 19:49 ` [PATCH v2 03/13] selftests/nolibc: waitpid_min: add waitid syscall support Zhangjin Wu
2023-05-29 19:50 ` [PATCH v2 04/13] tools/nolibc: add missing nanoseconds support for __NR_statx Zhangjin Wu
2023-05-29 21:39   ` Thomas Weißschuh
2023-05-30  5:21     ` Zhangjin Wu
2023-05-29 19:51 ` [PATCH v2 05/13] tools/nolibc: add more wait status related types Zhangjin Wu
2023-05-29 19:53 ` [PATCH v2 06/13] tools/nolibc: add pure 64bit off_t, time_t and blkcnt_t Zhangjin Wu
2023-05-29 19:54 ` [PATCH v2 07/13] tools/nolibc: sys_lseek: add pure 64bit lseek Zhangjin Wu
2023-05-30  8:10   ` Arnd Bergmann
2023-05-30 13:54     ` Zhangjin Wu
2023-07-02 16:28       ` Willy Tarreau
2023-05-29 19:56 ` [PATCH v2 08/13] tools/nolibc: add pure 64bit time structs Zhangjin Wu
2023-05-29 19:57 ` Zhangjin Wu [this message]
2023-05-29 19:58 ` [PATCH v2 10/13] tools/nolibc: sys_poll: add pure 64bit poll Zhangjin Wu
2023-05-29 19:59 ` [PATCH v2 11/13] tools/nolibc: sys_gettimeofday: add pure 64bit gettimeofday Zhangjin Wu
2023-05-29 20:01 ` [PATCH v2 12/13] tools/nolibc: sys_wait4: add waitid syscall support Zhangjin Wu
2023-05-29 20:03 ` [PATCH v2 13/13] selftests/nolibc: riscv: customize makefile for rv32 Zhangjin Wu
2023-06-02  4:06   ` Zhangjin Wu
2023-06-02 10:33     ` Thomas Weißschuh
2023-06-02 11:56       ` Zhangjin Wu
2023-05-30  6:33 ` [PATCH v2 0/2] nolibc: add part3 of support " Zhangjin Wu
2023-05-30  6:37   ` [PATCH 1/2] selftests/nolibc: add new gettimeofday test cases Zhangjin Wu
2023-05-30 10:59     ` Thomas Weißschuh
2023-05-30 11:28       ` Zhangjin Wu
2023-05-30 11:54         ` Thomas Weißschuh
2023-05-30 12:05       ` Willy Tarreau
2023-05-30 12:31         ` Andreas Schwab
2023-05-30 12:35         ` Thomas Weißschuh
2023-05-30  6:42   ` [PATCH 2/2] selftests/nolibc: add sizeof test for the new 64bit data types Zhangjin Wu
2023-05-30  9:18     ` Thomas Weißschuh
2023-05-30 11:17       ` Zhangjin Wu
2023-06-02 19:44 ` [PATCH v2 00/13] nolibc: add part2 of support for rv32 Willy Tarreau

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=fa047211708451779ddbfabeff749c4d692031ff.1685387484.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@weissschuh.net \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /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.
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).