From patchwork Thu Sep 14 16:01:20 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: 139867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp651930vqi; Thu, 14 Sep 2023 15:05:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOcgNDSXpH7CNqt4Fs3NE3iUVvqOcY2ydozINGnswjY2CRLxbibwY+Ml2khoEjKHTxjXuf X-Received: by 2002:a05:6a00:178e:b0:68b:eb3d:8030 with SMTP id s14-20020a056a00178e00b0068beb3d8030mr7826317pfg.1.1694729118077; Thu, 14 Sep 2023 15:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694729118; cv=none; d=google.com; s=arc-20160816; b=SaOIQvz3xIEagHMMATrMsg+9hXVx6BYQjO00Bi1FDJW2u7tWD85qPEkoONxYmyccxL 5bng/KEUyjK0valrnY945bQOEYWew/cg3PdBzXTQVqfPQB06QIlGzvgqX5LNXNAsHPSm 4gtwlf0+3jhrBQZYn4I2zikU8CCsFBMT3pVIfAIACZiu7sWtC1QlKKYBcYO/Jcr0oWZE KyqXIIgya31bm5s9SDCUWSKhD77bTV2czlBpzQc1eOZiTEoUzPsRRTGoFmytPQna/nYk 7rJDSgzEEa/M7o7xil+dgMXFUesUfICf/a5OeGeobtIEa582OPfrl8dsHiu8ZHVkXoTX k8fA== 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=w+mZslg83klDZg4HdBctlqgWb4VXPkwSh/vg2tJ5iSs=; fh=azYK+WW57en7GGRdjKWjQOHkHDsNRqF/+6hheqDI200=; b=rBrUI1/cUZk1d9wwHhFiF14/kAa99x/c6FEuESErYRUpnup/Jrz4g4GmcXCy6G3+hB O3p44bAnQcFTRbr7yfiU/kTCX6dbB8O0Lp7dcTm0LB5igDnWwwOJZFFXG8FVq9hjV9wm mmTHPkQikYriEJjlG15QaerXhHxYfVXGm3W9CFNOT7huUpG5XqXkPCUQT6xhf55sFVc4 Yh3z4GQcPhaKYZvlxc7MzTJ/+FopCOdZ+o4L8IBPoi7tQAi8Xl+yontp6Csvtlf9goVI eEGhEWrdj4g0bqKIpiuyGgZG7DnCTpL/YIPi4lvE2JPM13vn0sx4/Cl2tjzKYD2f7Ydi 9rbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=Y4CgCkNk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id k129-20020a632487000000b00573fcfe9f19si2151093pgk.283.2023.09.14.15.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 15:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=Y4CgCkNk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id C974D85BE6EC; Thu, 14 Sep 2023 09:02:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241740AbjINQCY (ORCPT + 34 others); Thu, 14 Sep 2023 12:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241677AbjINQCB (ORCPT ); Thu, 14 Sep 2023 12:02:01 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 390F32728; Thu, 14 Sep 2023 09:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1694707293; bh=zl3Xj+oQp2Dr3MQfACk4EonlZTHBYeQ+nfTgGzZOwVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Y4CgCkNksk2J13ulVehJe/Ytv0sKK+LNKe/GNZXCdeZIMaFoGW9OlGrjttaz0ylS7 8g4puMZEVbV9XFppWL5QlcvofBOAiR5tgNLSdD9NuZ2Pm7iohQOcRlAjM7DXz6bvSU /5r2kwjn23Ssc99K6I0h63VzuV3TANTgNMTVA9vo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Thu, 14 Sep 2023 18:01:20 +0200 Subject: [PATCH 4/4] tools/nolibc: automatically detect necessity to use pselect6 MIME-Version: 1.0 Message-Id: <20230914-nolibc-syscall-nr-v1-4-e50df410da11@weissschuh.net> References: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@weissschuh.net> In-Reply-To: <20230914-nolibc-syscall-nr-v1-0-e50df410da11@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=1694707292; l=3914; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zl3Xj+oQp2Dr3MQfACk4EonlZTHBYeQ+nfTgGzZOwVE=; b=F8EbEV7tGvVpu68Qr3EK6RIfDob0u0Yj2Wok7lOtDs9Z1s+WoEBEmIuIiU5hgIybWgIAnW2VT o284s51I2qYDdkhTq5ZYHZcd9Vboi/EkkwezL5N2eZpLKzuMwT1pykA X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 09:02:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777052279504541435 X-GMAIL-MSGID: 1777052279504541435 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 --- 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 d96f2aa7d987..dbf5cc92181b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -946,7 +946,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) { @@ -954,10 +958,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 (void)nfds; (void)rfds;