From patchwork Wed Aug 23 22:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 1825013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20221208.gappssmtp.com header.i=@rivosinc-com.20221208.gappssmtp.com header.a=rsa-sha256 header.s=20221208 header.b=GTnL/5uA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RWLZ40vyTz1yNm for ; Thu, 24 Aug 2023 08:32:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33E723882AD0 for ; Wed, 23 Aug 2023 22:32:26 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id D4ABF3850404 for ; Wed, 23 Aug 2023 22:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4ABF3850404 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bf092a16c9so48249885ad.0 for ; Wed, 23 Aug 2023 15:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1692829903; x=1693434703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V0QqkAAWiEyNKG93cR9qzCkSsz8yqQX1gfSOrM8MtYM=; b=GTnL/5uAIUg0PDTbZ04nQ9Art/ZO632VYAG4Gi9IhcbZ2D3B8jGePTm5LRMyxvnqtA JkYSoBUBDcqvz+3TuFM1k9vZKan/lKC7qYsnCEBMkBIVBdtjgO/8nMJlY/TecwqScc7F XkPYg8NFulCxQyGCC2iGI0NRtHlvVf38zpmKPbQD+WuQcJObwwTO7r5rvf7h6rqMwldm YngTp6D5G6tH6aKoYWfru6pz2AQFMKaH0HHn8NOYBmXdx8Shiojngk/ZqJf4H7Q0/mgi uTudUZCrt3EloTAqkTOMvQ9TMdRvfUoysiR+R1YKIarBLpfvU64ybBehde+HaB7CkAGN D62A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692829903; x=1693434703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V0QqkAAWiEyNKG93cR9qzCkSsz8yqQX1gfSOrM8MtYM=; b=KgwFc6Z72zHMsjc/XrM9l7xGdPWsHSjgHByRicx7+/8GJZZFstfaBKZi7UzCAyjBhh oljxtrFYJLSu2DErijVR3Ts78FtdqjMy7jGDo8SFQqJbJPvFa5zb+MzNFH62Iv/O6MST bJs9g0UFvuJ5CzUifOOh65Fz1cxORmsRPYhGRinISlxD1vM7g54lKgPQIooYSsMNmox6 mSUbvnP413xrp0eYHX/b+u4SofjFTv4zHju0dCqOWMF8Ea83lJCfrMWqvob5bSYfIAnM KdMgT13n0oeywMxQjIZm5d03+DJay5Dm4ctlSBqJw50n4SC52AhmV4gu/dxzb1tW6JA+ Xa7A== X-Gm-Message-State: AOJu0YwiRcqbFXF9FadbEmstG98TLAoyN8Ss4p01DBwtsWKPJd8MwnfP pRrmK08KFZrF1waVnGWJShyqWWeMm9dfguKzZpA= X-Google-Smtp-Source: AGHT+IH+k0cYEgAEKWc2slsS4yjieErRWRhvsHFZFoLKxiA2egjJwVyO1F348EDgL+dcPH8B9SSECw== X-Received: by 2002:a17:902:d2c4:b0:1bd:e64c:5c7e with SMTP id n4-20020a170902d2c400b001bde64c5c7emr15573822plc.61.1692829903539; Wed, 23 Aug 2023 15:31:43 -0700 (PDT) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id i1-20020a17090332c100b001bbf7fd354csm11335150plr.213.2023.08.23.15.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 15:31:43 -0700 (PDT) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, palmer@rivosinc.com, Florian Weimer , slewis@rivosinc.com, Evan Green Subject: [PATCH v7 5/6] riscv: Add ifunc helper method to hwprobe.h Date: Wed, 23 Aug 2023 15:31:14 -0700 Message-Id: <20230823223116.645225-6-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823223116.645225-1-evan@rivosinc.com> References: <20230823223116.645225-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Add a little helper method so it's easier to fetch a single value from the hwprobe function when used within an ifunc selector. Signed-off-by: Evan Green --- Changes in v7: - Introduced static inline helper (Richard) sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h index fd3be5a411..7378b1baa2 100644 --- a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h +++ b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h @@ -22,6 +22,7 @@ #include #include +#include #ifdef __has_include # if __has_include () # include @@ -79,4 +80,27 @@ typedef int (*__riscv_hwprobe_t) (struct riscv_hwprobe *__pairs, size_t __pair_c __END_DECLS +/* Helper function usable from ifunc selectors that probes a single key. */ +static inline int __riscv_hwprobe_one(__riscv_hwprobe_t hwprobe_func, + signed long long int key, + unsigned long long int *value) +{ + struct riscv_hwprobe pair; + int rc; + + if (!hwprobe_func) + return ENOSYS; + + pair.key = key; + rc = hwprobe_func(&pair, 1, 0, NULL, 0); + if (rc) + return rc; + + if (pair.key < 0) + return ENOENT; + + *value = pair.value; + return 0; +} + #endif /* sys/hwprobe.h */