[PATCH v2 10/13] tools/nolibc: sys_poll: add pure 64bit poll

Zhangjin Wu falcon at tinylab.org
Mon May 29 12:58:42 PDT 2023


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

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

Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
 tools/include/nolibc/sys.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index db648b5b9a1c..ca802627e88f 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -940,14 +940,21 @@ int pivot_root(const char *new, const char *old)
 static __attribute__((unused))
 int sys_poll(struct pollfd *fds, int nfds, int timeout)
 {
-#if defined(__NR_ppoll)
+#if defined(__NR_ppoll) || defined(__NR_ppoll_time64)
+#ifdef __NR_ppoll_time64
+	const long nr_ppoll = __NR_ppoll_time64;
+#elif __SIZEOF_LONG__ == 8
+	const long nr_ppoll = __NR_ppoll;
+#else
+#error No __NR_ppoll_time64 defined, cannot implement time64 sys_poll()
+#endif
 	struct timespec t;
 
 	if (timeout >= 0) {
 		t.tv_sec  = timeout / 1000;
 		t.tv_nsec = (timeout % 1000) * 1000000;
 	}
-	return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
+	return my_syscall5(nr_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
 #elif defined(__NR_poll)
 	return my_syscall3(__NR_poll, fds, nfds, timeout);
 #else
-- 
2.25.1




More information about the linux-riscv mailing list