]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/nolibc: automatically detect necessity to use pselect6
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 17 Sep 2023 15:36:19 +0000 (17:36 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Thu, 12 Oct 2023 19:14:13 +0000 (21:14 +0200)
We can automatically detect if pselect6 is needed or not from the kernel
headers. This removes the need to manually specify it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20230917-nolibc-syscall-nr-v2-4-03863d509b9a@weissschuh.net
tools/include/nolibc/arch-aarch64.h
tools/include/nolibc/arch-loongarch.h
tools/include/nolibc/arch-riscv.h
tools/include/nolibc/sys.h

index 6c33c46848e36ecf9a63b7c4d193987fb9eae6e4..b23ac1f04035e07c973ff70c34c0f3cde882228c 100644 (file)
  *   - 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)                                                      \
 ({                                                                            \
index bf98f6220195c03afd58e0b63a0d6aa656060e90..3f8ef8f86c0f10c1ef38ee2bcd2fb9bea0a13317 100644 (file)
  *   - 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 _NOLIBC_SYSCALL_CLOBBERLIST \
        "memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8"
 
index 950cc2283fd7ff8dbdac136a81118eb05c1ceddd..1927c643c7395052ed0161179782500a245cb2f1 100644 (file)
  *   - 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)                                                      \
 ({                                                                            \
index f05144e46b675eb35095967d0e7861b85f4a3989..2f359cb03d106fa7319886ab59f55d6ec08f9546 100644 (file)
@@ -930,7 +930,11 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
                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)
+#elif defined(__NR__newselect)
+       return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
+#elif defined(__NR_select)
+       return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout);
+#elif defined(__NR_pselect6)
        struct timespec t;
 
        if (timeout) {
@@ -938,10 +942,6 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
                t.tv_nsec = timeout->tv_usec * 1000;
        }
        return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
-#elif defined(__NR__newselect)
-       return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
-#elif defined(__NR_select)
-       return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout);
 #else
        return __nolibc_enosys(__func__, nfds, rfds, wfds, efds, timeout);
 #endif