From patchwork Sun Sep 17 15:36:16 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: 13388605 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 50CDCCD37B4 for ; Sun, 17 Sep 2023 15:36:33 +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=kQx0N+p3Zo17+x9MGERA4/cCP+XWfEbmrTlI4yWOfZA=; b=QiGwlwxO1o3ibU XsWMktMF33hauDK6ApeoH6cjKFESKOVlRDVrJqy795wmxGbYKCTBlEfRUkvc4aIZMTZ4dLp4nE0L6 8kmTLROfkTJhUuKIHXLASsQb6ewxQGN8RN0PcW5WBrmWmZwq4ygiqdTncOp6hX6mZbzKNjl5CZ493 HGmMI6ijenof0hVBRJHxIUbAW7191hw6n3pkPUAw3mFWGCbxrs1GzCFNjAE8Y97vGoepKNa1hvGpu 6P/iZz+sfFoHlxxaeWJrZwBqgKtP6WI2SXsbojRIs1dmHDZ7mkyUpykAGskGDiOiz+sfyfC/F8XfZ 39fw1sklJhn3Q5ANlUGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhtou-00DmTk-0N; Sun, 17 Sep 2023 15:36:24 +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 1qhtor-00DmSw-0i for linux-riscv@lists.infradead.org; Sun, 17 Sep 2023 15:36:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694964978; bh=CFKO2pFyHSsA2SAs6y1PywroFir3M35jZ1f8rQL8DIY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=grweBFpqOzzFodwt9bLiUu+iq1fDMCCV2KbU7oR61uO2DmX1YY996TpBvk7O55JWO xmpwXzKtSjaPDyNqHTfld80fPCdkamOBDhFuxIwsU0gseEI5uHVIi3hKI4fjxAn6l9 e/vQ3wCQOrQmVcPn0IvSKP6+XmhT/h0A/DjEXF/M= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 17 Sep 2023 17:36:16 +0200 Subject: [PATCH v2 1/4] selftests/nolibc: allow building i386 with multiarch compiler MIME-Version: 1.0 Message-Id: <20230917-nolibc-syscall-nr-v2-1-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=951; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=CFKO2pFyHSsA2SAs6y1PywroFir3M35jZ1f8rQL8DIY=; b=VsixQu3g8WzopT9PImr31pRBaIq13lYqmy67LYfor/qIj3rHz5UPsZREaLxJr7ILn1LXxrUI/ IpcQwNaSusPDo9KxxDvHj6wODfe0BMy1Lf52vkb0+30THRM1jrRkwrJ 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_083621_430535_2CDAEE8A X-CRM114-Status: UNSURE ( 6.68 ) X-CRM114-Notice: Please train this message. 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 When building with a multiarch-capable compiler, like those provided by common distributions the -m32 argument is required to build 32bit code. Wrap it in cc-option in case the compiler is not multiarch-capable. Acked-by: Willy Tarreau Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 689658f81a19..19096a9ded55 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -113,6 +113,7 @@ else Q=@ endif +CFLAGS_i386 = $(call cc-option,-m32) CFLAGS_ppc = -m32 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64 = -m64 -mbig-endian -mno-vsx $(call cc-option,-mmultiple) CFLAGS_ppc64le = -m64 -mlittle-endian -mno-vsx $(call cc-option,-mabi=elfv2) From patchwork Sun Sep 17 15:36:17 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: 13388608 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 42561CD13D2 for ; Sun, 17 Sep 2023 15:36:38 +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=PyUtICfhSi9LFPXQMSDc3NoeFl66CRMCaNrUMpTsFao=; b=R66WgmipjMDOjV DA+DNsJ73U+C34Hc7Tn+tGbuzPGAMF7ehbLlJQ+EmnpqECntBw1P8KJ10fCzyzqUdEQFx5xlcwWHf Rt3gZRR9D4GhvAfybdEyj37RezTESt4uPS0zm9d6v5fVWIVDAVAPi0qnm2aAbBYsD/wPOIsnDhsE/ kfA3+AtLhheIHftmSqLf+TNx7zo9I/wXNfqpcLZdn0W5lwmPrKzAK5rklY4IUjCdzLwzYpzwPq8v4 476/Nc/wW2oDOIOfX1iAH/9ZBsaOMnAsrqF/yddvUDCmSn+hyhgBp5EmeaDrGFd700Y9JK/liucfj +yTbAjibt9EW5ypbZSXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhtp4-00DmWE-1H; Sun, 17 Sep 2023 15:36:34 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qhtp0-00DmUj-0h for linux-riscv@lists.infradead.org; Sun, 17 Sep 2023 15:36:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694964988; bh=Kd7GKLDLXksFJfiA80JZxSw1ujvuMQ52Z8zyi0PXrrE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uGZi+a2s7YCC8X6OXifmQaalx/UCazKGCDAcBs8bKPudTZomZNr2C+WM+oNU/oPat S6H5T9pHI1a0ur2zWBrJ3FiuQr1E+uQuuulL9K8o+g/dBMdVjH7jIHJzntn0UdFuU/ IxLPQaiB/wlHGLbyqUKHma2GBSgMPA8fNT+JU47k= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 17 Sep 2023 17:36:17 +0200 Subject: [PATCH v2 2/4] tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks MIME-Version: 1.0 Message-Id: <20230917-nolibc-syscall-nr-v2-2-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=5233; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=Kd7GKLDLXksFJfiA80JZxSw1ujvuMQ52Z8zyi0PXrrE=; b=XwOvyRGPpz62PEO1mHwwgUjtiZze0jEapfYPwOr/ySCCHaaVfpWLRDWMJiJ/WnglbeDyEn4Ia Zc2jwm89BSjDozRCzvUCpAXOVCGkctGNX1iWn6TZzLmV+CwxyNSf9tT 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_083630_416089_6D6A19CA X-CRM114-Status: UNSURE ( 7.88 ) X-CRM114-Notice: Please train this message. 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 The ENOSYS fallback code does not use its functions parameters. This can lead to compiler warnings about unused parameters. Explicitly avoid these warnings. Signed-off-by: Thomas Weißschuh Acked-by: Willy Tarreau --- tools/include/nolibc/sys.h | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b478750c9004..8389820e1928 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -43,6 +43,16 @@ : __sysret_arg; /* return original value */ \ }) +/* Syscall ENOSYS helper: Avoids unused-parameter warnings and provides a + * debugging hook. + */ + +static __inline__ int __nolibc_enosys(const char *syscall, ...) +{ + (void)syscall; + return -ENOSYS; +} + /* Functions in this file only describe syscalls. They're declared static so * that the compiler usually decides to inline them while still being allowed @@ -133,7 +143,7 @@ int sys_chmod(const char *path, mode_t mode) #elif defined(__NR_chmod) return my_syscall2(__NR_chmod, path, mode); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path, mode); #endif } @@ -156,7 +166,7 @@ int sys_chown(const char *path, uid_t owner, gid_t group) #elif defined(__NR_chown) return my_syscall3(__NR_chown, path, owner, group); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path, owner, group); #endif } @@ -230,7 +240,7 @@ int sys_dup2(int old, int new) #elif defined(__NR_dup2) return my_syscall2(__NR_dup2, old, new); #else - return -ENOSYS; + return __nolibc_enosys(__func__, old, new); #endif } @@ -312,7 +322,7 @@ pid_t sys_fork(void) #elif defined(__NR_fork) return my_syscall0(__NR_fork); #else - return -ENOSYS; + return __nolibc_enosys(__func__); #endif } #endif @@ -486,7 +496,7 @@ int sys_gettimeofday(struct timeval *tv, struct timezone *tz) #ifdef __NR_gettimeofday return my_syscall2(__NR_gettimeofday, tv, tz); #else - return -ENOSYS; + return __nolibc_enosys(__func__, tv, tz); #endif } @@ -563,7 +573,7 @@ int sys_link(const char *old, const char *new) #elif defined(__NR_link) return my_syscall2(__NR_link, old, new); #else - return -ENOSYS; + return __nolibc_enosys(__func__, old, new); #endif } @@ -584,7 +594,7 @@ off_t sys_lseek(int fd, off_t offset, int whence) #ifdef __NR_lseek return my_syscall3(__NR_lseek, fd, offset, whence); #else - return -ENOSYS; + return __nolibc_enosys(__func__, fd, offset, whence); #endif } @@ -607,7 +617,7 @@ int sys_mkdir(const char *path, mode_t mode) #elif defined(__NR_mkdir) return my_syscall2(__NR_mkdir, path, mode); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path, mode); #endif } @@ -629,7 +639,7 @@ int sys_rmdir(const char *path) #elif defined(__NR_unlinkat) return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path); #endif } @@ -652,7 +662,7 @@ long sys_mknod(const char *path, mode_t mode, dev_t dev) #elif defined(__NR_mknod) return my_syscall3(__NR_mknod, path, mode, dev); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path, mode, dev); #endif } @@ -742,7 +752,7 @@ int sys_open(const char *path, int flags, mode_t mode) #elif defined(__NR_open) return my_syscall3(__NR_open, path, flags, mode); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path, flags, mode); #endif } @@ -842,7 +852,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) #elif defined(__NR_poll) return my_syscall3(__NR_poll, fds, nfds, timeout); #else - return -ENOSYS; + return __nolibc_enosys(__func__, fds, nfds, timeout); #endif } @@ -934,7 +944,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva #endif return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); #else - return -ENOSYS; + return __nolibc_enosys(__func__, nfds, rfds, wfds, efds, timeout); #endif } @@ -989,7 +999,7 @@ int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct sta #ifdef __NR_statx return my_syscall5(__NR_statx, fd, path, flags, mask, buf); #else - return -ENOSYS; + return __nolibc_enosys(__func__, fd, path, flags, mask, buf); #endif } @@ -1047,7 +1057,7 @@ int sys_symlink(const char *old, const char *new) #elif defined(__NR_symlink) return my_syscall2(__NR_symlink, old, new); #else - return -ENOSYS; + return __nolibc_enosys(__func__, old, new); #endif } @@ -1104,7 +1114,7 @@ int sys_unlink(const char *path) #elif defined(__NR_unlink) return my_syscall1(__NR_unlink, path); #else - return -ENOSYS; + return __nolibc_enosys(__func__, path); #endif } @@ -1127,7 +1137,7 @@ pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage) #ifdef __NR_wait4 return my_syscall4(__NR_wait4, pid, status, options, rusage); #else - return -ENOSYS; + return __nolibc_enosys(__func__, pid, status, options, rusage); #endif } From patchwork Sun Sep 17 15:36:18 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: 13388607 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 3DDA6CD13D1 for ; Sun, 17 Sep 2023 15:36:38 +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=9KdOaz6eURazfdLw5/U+fqdjhUh9t9I1W2NbGPYN+UQ=; b=OhtLfI8/+ZIdz3 /t9wKglvXsv9DotPuHlsOPoaHkATQxaHMKfMMjwFZpMhw8rgoCUmno39oToYr19Q7PiArIGXUWDOk so192Sczs2VaxbnXs6WRrngOXFDyTHjvUryt7VMKfFVyIbN0LhtYZJnkfg7nPY/9Aq+qulqm/UfLK mVpJxO92XrvHhbv7SgN7TXjPmYo1B+U3fAmMEqGGf4n8XdsA0p+D04JI4oSL840Bxcty6/1vPIZfN 861UH4GhLXIsdcitxjCzKaaIKiZ3oshDFuwMgVHnWPld8d5MC6RixEPvtIwZ9eLQsH7XFzow0DhN4 WXR5vBzPPgxtjgRxaxuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qhtp3-00DmVw-2Y; Sun, 17 Sep 2023 15:36:33 +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-00DmUk-0y for linux-riscv@lists.infradead.org; Sun, 17 Sep 2023 15:36:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694964988; bh=1NF2q2upNDj9/vMoCeQiX+AUEvsHPwNOqql4WRWM0Oo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PDYejELIHl1QbGAiIMk2tjDMYzW5D/26ieLRdJoDq4IaTyoVPh1QrNKnygwKUNiyQ Jyq+SfmCXjK1lWJGagf0A1MIMPRtCVraCZ4msErQL5i0VSvBxSvi3l0V196nHbXq8R /DTqZOqSbTaMg3kxexEOJoRNXkEGRbzQK9KDv0pA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 17 Sep 2023 17:36:18 +0200 Subject: [PATCH v2 3/4] tools/nolibc: don't define new syscall number MIME-Version: 1.0 Message-Id: <20230917-nolibc-syscall-nr-v2-3-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=1312; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1NF2q2upNDj9/vMoCeQiX+AUEvsHPwNOqql4WRWM0Oo=; b=HyWIKvOvEBDaT6rG3/p9D3aiZMZ5Ewl218rM+RUJeFdyJLTOV1Ab2odZNX32VYVmiMtWLk1w/ htVnUFszqpVBrAyuiLAygf5fExGiweKx2+F3qUtWHRT8SHuTrjU4bcw 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_083630_492143_6A880DB4 X-CRM114-Status: UNSURE ( 6.68 ) X-CRM114-Notice: Please train this message. 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 All symbols created by nolibc are also visible to user code. Syscall constants are expected to come from the kernel headers and should not be made up by nolibc. Refactor the logic to avoid defining syscall numbers. Also the new code is easier to understand. Acked-by: Willy Tarreau Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 8389820e1928..f05144e46b67 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -938,11 +938,10 @@ 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) || defined(__NR_select) -#ifndef __NR__newselect -#define __NR__newselect __NR_select -#endif +#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 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