Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp527410rdg; Thu, 12 Oct 2023 12:33:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMq79Zn2Tbdw+N3Cq9/bmiMm1q8FcRSQVqjzfuRAQwoDmdKPcUwLiIjs1y1Hsjl/fGttBd X-Received: by 2002:a17:90a:1992:b0:27d:2dde:5979 with SMTP id 18-20020a17090a199200b0027d2dde5979mr976980pji.5.1697139227083; Thu, 12 Oct 2023 12:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139227; cv=none; d=google.com; s=arc-20160816; b=UGWKixR3iX3TYbuKMCWQ1ibtatziu4GpzpnIi7TczcMNkiKAyi2kRoXm6ral9vSunD ko2PmP54GlvyjxcjeSi+0SE9Qlc926OkUMxdMqDR8qZSWVFgHTiAXX3eV9kf1Vfm50g3 IM4z1PC06ygisZu4iQ4wT/YRkl8yN5MUIsio11sJwwHclM2fz0VtMR/Nbho3fDjHLZR2 ePTu7S79NaQdzZdl1S5wZvrshVMhiolfH01EoWaoaEEenjixmc6xAf5LuY217ccAisDW mL7RGxiNfaaCiy52KkcClXG0TYB6IHGVmlG4VXkgVYDoe9MB7LbO0MJpg3cQrWUyQkiP Kvow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zwx22bQOCULpYuzyGQPdXfAjYH1TNN9j0otxEp3QOh4=; fh=n5S/AR14tYMsjDdXEOPrR3UbxswSa5eTzDqlfcgbnjE=; b=Q9UbaUL+dRMUaVxeAsyMBmlWs2eVeE6zSwK0eEyGdy8aIuhdXQVBlFxAe79TZ42fL1 e1gqyoUMGEOdi802h0V2p2qpPQUQKjMpBtGQRCIS5kTE2VVxy+uJdnKiizP7mLNmiYP4 aePRrhLprXgsuNZerT+tLsbhZ+G2kpZxWumStbWlzJX+MsTlGe4hHlXrt6l4SXDXEdNP yckIYPRGh8BtYV3l2HK7vKFicFm0Vth4Xby6HOUzN2Qu66o4hUVEZazne5CoUNHlkgCo hzWOT1YaVhDnZtPTKLQast6FW40PFoVYTFDg6PSBsfA8Cd8RFNetR3S6iwDa6lOvywVm EbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RsAhwNai; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id nn13-20020a17090b38cd00b00276b87c8b8esi1636804pjb.59.2023.10.12.12.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:33:47 -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=@kernel.org header.s=k20201202 header.b=RsAhwNai; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5D0A3828B8EB; Thu, 12 Oct 2023 12:33:46 -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 S1442547AbjJLTdg (ORCPT + 99 others); Thu, 12 Oct 2023 15:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442348AbjJLTcl (ORCPT ); Thu, 12 Oct 2023 15:32:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF658E3 for ; Thu, 12 Oct 2023 12:32:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49FC6C433B6; Thu, 12 Oct 2023 19:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697139156; bh=TkAOAZUUquEC/SVcrwpY1Lnr3+lwFbze2yyE+P3apL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsAhwNai9jEsJF0WuQAdObMqc8i/7+jCDlQmFkI3yPc6csW9jO8ZWX9TT6SMOu0Bv pnvXJJ/88ZkOs12lZybvCSiiCTgyvp88IiQt9M1e43MPbRhb+Rw7wQm+TRz71P4u0f jnVzH/ufeeOH7F0XSff4TvteXRJH/dKVYEmCKDV/BgWT0Io+vYv50lP5hvUXj2K/+Y 7b0zQNVUVupGMX1nqQHcnrT4YMcpE3gvIHHcnDlEpnAnIrO/a+qNKMqHxXMlfjWHKj bbxrm9EtB7c/pUD+nlv+/X0RQa/K/xIbihwViEqzWEyAqsg5rqNBzy3RlGgksiU2Rv lxbJTHN4QNKiA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 605C3CE0DEA; Thu, 12 Oct 2023 12:32:35 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Willy Tarreau Subject: [PATCH nolibc 15/19] tools/nolibc: automatically detect necessity to use pselect6 Date: Thu, 12 Oct 2023 12:32:29 -0700 Message-Id: <20231012193233.207857-15-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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]); Thu, 12 Oct 2023 12:33:46 -0700 (PDT) From: Thomas Weißschuh 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 Acked-by: Willy Tarreau Link: https://lore.kernel.org/r/20230917-nolibc-syscall-nr-v2-4-03863d509b9a@weissschuh.net --- 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.40.1