Skip to content

Commit eaa8c9a

Browse files
committed
tools/nolibc: automatically detect necessity to use pselect6
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 <[email protected]> Acked-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e7b28f2 commit eaa8c9a

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

tools/include/nolibc/arch-aarch64.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
* - the arguments are cast to long and assigned into the target registers
2121
* which are then simply passed as registers to the asm code, so that we
2222
* don't have to experience issues with register constraints.
23-
*
24-
* On aarch64, select() is not implemented so we have to use pselect6().
2523
*/
26-
#define __ARCH_WANT_SYS_PSELECT6
2724

2825
#define my_syscall0(num) \
2926
({ \

tools/include/nolibc/arch-loongarch.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
* - the arguments are cast to long and assigned into the target
2020
* registers which are then simply passed as registers to the asm code,
2121
* so that we don't have to experience issues with register constraints.
22-
*
23-
* On LoongArch, select() is not implemented so we have to use pselect6().
2422
*/
25-
#define __ARCH_WANT_SYS_PSELECT6
23+
2624
#define _NOLIBC_SYSCALL_CLOBBERLIST \
2725
"memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8"
2826

tools/include/nolibc/arch-riscv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
* - the arguments are cast to long and assigned into the target
2020
* registers which are then simply passed as registers to the asm code,
2121
* so that we don't have to experience issues with register constraints.
22-
*
23-
* On riscv, select() is not implemented so we have to use pselect6().
2422
*/
25-
#define __ARCH_WANT_SYS_PSELECT6
2623

2724
#define my_syscall0(num) \
2825
({ \

tools/include/nolibc/sys.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -930,18 +930,18 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
930930
struct timeval *t;
931931
} arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout };
932932
return my_syscall1(__NR_select, &arg);
933-
#elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6)
933+
#elif defined(__NR__newselect)
934+
return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
935+
#elif defined(__NR_select)
936+
return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout);
937+
#elif defined(__NR_pselect6)
934938
struct timespec t;
935939

936940
if (timeout) {
937941
t.tv_sec = timeout->tv_sec;
938942
t.tv_nsec = timeout->tv_usec * 1000;
939943
}
940944
return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
941-
#elif defined(__NR__newselect)
942-
return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
943-
#elif defined(__NR_select)
944-
return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout);
945945
#else
946946
return __nolibc_enosys(__func__, nfds, rfds, wfds, efds, timeout);
947947
#endif

0 commit comments

Comments
 (0)