Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5841333rdb; Sun, 17 Sep 2023 15:16:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaFA+vyoi/2Aojdm8YiTpfzRnGarSU0iruXXDJ9bdubiM+rrLhOB8A82y1qDyEG2zdYzOw X-Received: by 2002:a05:6a00:3186:b0:690:1857:3349 with SMTP id bj6-20020a056a00318600b0069018573349mr6221182pfb.25.1694988974390; Sun, 17 Sep 2023 15:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694988974; cv=none; d=google.com; s=arc-20160816; b=Rhhncll8V5qpGUupi6x9yOctXAbp2kDMJmKviupr8YnjtAT1etBaE9KTo1tFnUETGf 9M2xSS6zK2gNxQ6xTiTF9ncE7sZGenjgozE8FdHvuQhGpeHE4DjiBCjU3sUvzgIYP7l1 VVeovT8ORhLS90nv1qdkDec4ZLEt4DR7O6TITY8RoFe3cjF9b/IP7R5mSo77L1cYFENp WyGPxBT9gZfD2Z8nGbO4xKChqGIzfmVu3snECSi2VkOwDstXdk6LXxUCA0Nx9gb2+Gno YQgMZ614O+zZQtWiJbigsJzvecGIDGpg69K57rZ31GZvlxMGtYdnZOr7CtUY65u0+a/X E/Wg== 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 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ch14-20020a056a00288e00b0068e3efe866esi6903765pfb.146.2023.09.17.15.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 15:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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 2620:137:e000::3:7 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 078FA81A6E59; Sun, 17 Sep 2023 08:37:49 -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 S237534AbjIQPhU (ORCPT + 99 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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:49 -0700 (PDT) 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 -- 2.42.0