From patchwork Sun Sep 17 15:36:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13388609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5646FCD13CF for ; Sun, 17 Sep 2023 15:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mToPzd/cjryy/+bYWisa8JUf3UThwA8JPic4/3+g6v4=; b=sKOu3DjUzogOX7 anZPYcbJTz6gWhvkgPMb6xh8gha8m7khesF9M6lqUOBOQ9XH3ZxHNxx7YD0qqmA40OFZUOWC8cPZ+ qI0Gyp57PVI5zLFIMM/gCedeIpTSvQuYWinc1Tx/PBDgr3Iu+AjjJ2PoQ+RmPHbkmif+9WMEt1hdb USLfGq2Sg3QwejNmou4G5a/w6+Z3Y9jKiaVW4ACfY3k4o2BynnnK9zdUxkWSiTywPMb+v6i4CUyBi lB/bVLEQTL4NwU0MayUGN3f553g7gj+deg6RtydapbVmrSakgN0QxYq+XBwDHcqVmGnYOHz1i+lQ7 ydMYGWn1Mnn6AXvx7t7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhtp7-00DmWu-09; Sun, 17 Sep 2023 15:36:37 +0000 Received: from todd.t-8ch.de ([159.69.126.157]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhtp0-00DmUo-30 for linux-riscv@lists.infradead.org; Sun, 17 Sep 2023 15:36:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694964989; bh=8OF18RXUU5eFusbx27aPN1t2ODt6bcVmev+mbNqOz2A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jVF/GO+twJAwA+z9XJbBE9vdpIcr9l9BFC6GtZzdTFXXA9z6H36B8LppsioT8hRl5 s5bEcUZpBoz1Tr+IARCSNrZcRfhREWq7taNBndr6ZiyjvP78UGFp+Sz4oOAzCiSUwN YGNxxign8gznWncWSWAJqkakwDV+JSMZMSUzf28s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 17 Sep 2023 17:36:19 +0200 Subject: [PATCH v2 4/4] tools/nolibc: automatically detect necessity to use pselect6 MIME-Version: 1.0 Message-Id: <20230917-nolibc-syscall-nr-v2-4-03863d509b9a@weissschuh.net> References: <20230917-nolibc-syscall-nr-v2-0-03863d509b9a@weissschuh.net> In-Reply-To: <20230917-nolibc-syscall-nr-v2-0-03863d509b9a@weissschuh.net> To: Willy Tarreau , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1694964977; l=3999; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8OF18RXUU5eFusbx27aPN1t2ODt6bcVmev+mbNqOz2A=; b=r70FaDa0oXnB5g6rG9xiPUzpbzaTBrRLIFecxT5GyLpgj8QqFZA7eO8sFNrih0oVELZmQUBUj VIwaqhgVNWHA+sXZ3pLas5fa/tW43zzi/VZugDaqLPIosnDX05BTNPN X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230917_083631_123040_483D8098 X-CRM114-Status: GOOD ( 10.60 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We can automatically detect if pselect6 is needed or not from the kernel headers. This removes the need to manually specify it. Acked-by: Willy Tarreau Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/arch-aarch64.h | 3 --- tools/include/nolibc/arch-loongarch.h | 4 +--- tools/include/nolibc/arch-riscv.h | 3 --- tools/include/nolibc/sys.h | 10 +++++----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h index 6c33c46848e3..b23ac1f04035 100644 --- a/tools/include/nolibc/arch-aarch64.h +++ b/tools/include/nolibc/arch-aarch64.h @@ -20,10 +20,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 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 bf98f6220195..3f8ef8f86c0f 100644 --- a/tools/include/nolibc/arch-loongarch.h +++ b/tools/include/nolibc/arch-loongarch.h @@ -19,10 +19,8 @@ * - 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" diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index 950cc2283fd7..1927c643c739 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -19,10 +19,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 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 f05144e46b67..2f359cb03d10 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -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