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: 141172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2248637vqi; Sun, 17 Sep 2023 11:17:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6Ww0L4wxMc0Z4gPIx6O4cdPCQGQ/W6UgG8UhHDqTyOo20f6dhFAhR+qqvA6LQ9i0KjUmi X-Received: by 2002:a05:6a21:7189:b0:157:eb32:e739 with SMTP id wq9-20020a056a21718900b00157eb32e739mr6973745pzb.32.1694974650414; Sun, 17 Sep 2023 11:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694974650; cv=none; d=google.com; s=arc-20160816; b=j78vlk5xZQEt4RYUDmVjPz4ETKmDxi9xM0MKKF1THi6UZ4ZWHckgbwfUzewB8zGWC+ lpJ+AeZJrCoNvd4l0WdhYcLjZjtU87pf2bz524aLtYTj3PJU/zmlBrD8+31XihpvtZwY 5Q5ow8RRVnh9wgZtyaQLZGCmD1/RMgDpWtbOgB/OiSnGusVpESEIkuvw+Lb132TI5wki NHR41pLtXZQhK5WVwXGcK/IEpHGOjy12b9kSZm1qreZwpIYy9uuOYyCrLwURMk522hQ7 6ixEq0oG+Ul+8FzekNO7x7LrYCu6IzZhLfiwjJPCB+1wVLQloPx2JwlxIxNsrPMLbcX9 4Rxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=dwPp9m0jnNznNxq9+wbBeQTrnC8dEZf3Pm0agsAiKHA=; fh=azYK+WW57en7GGRdjKWjQOHkHDsNRqF/+6hheqDI200=; b=T5Lvvr4zkSV63sphWNjs29muef3K5P1GjxSMU8n9S6rS431hxSkSQFbW7qHKFagENP HtJ+vy34L9MJPuCRcgnjBRrYtRLp9eqlgaej+XTsIvMTcJEDsHtlbBkGl1zlWomAK5nG jzlcK8PxF7cxr37x7SFj8IZ00aF5xzW8sHIbMG8j0DNacsMOqq0Cyex6yK+BIrhXZ5+N gYY0MJa5IwhLaa96kCM5s68/nXik/zGOm5gV/4C2UQ95XA0MgHLMK2RCkwQ4sEN0mBIG z00u0ZnkOrWeswStoq3KZqQXgW6s1uXgbEzq1cj4L4+J1tyf+zYcj7zyT9oqo+2tqAKm F0xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="jVF/GO+t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e186-20020a6369c3000000b0056fad9586d2si6501168pgc.429.2023.09.17.11.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="jVF/GO+t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BC69A81A43F5; Sun, 17 Sep 2023 08:37:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237535AbjIQPhU (ORCPT + 29 others); Sun, 17 Sep 2023 11:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236757AbjIQPgg (ORCPT ); Sun, 17 Sep 2023 11:36:36 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 070A4120; Sun, 17 Sep 2023 08:36:31 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:37:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777309739240584996 X-GMAIL-MSGID: 1777309739240584996 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