From patchwork Fri Sep 1 23:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 1829021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=TZ0u2yF3; 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 4RcvxZ6RCsz1ygF for ; Sat, 2 Sep 2023 09:53:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F19213858C39 for ; Fri, 1 Sep 2023 23:53:36 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id B92583856DDA for ; Fri, 1 Sep 2023 23:52:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B92583856DDA 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-x630.google.com with SMTP id d9443c01a7336-1bf078d5f33so20985115ad.3 for ; Fri, 01 Sep 2023 16:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1693612360; x=1694217160; darn=sourceware.org; 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=4M4T9oKuv8pbgdqOgTCb0F93HmJB1LDIToIgnoaj87w=; b=TZ0u2yF3UFTVuWip8cXKZ0sUa8Po/8hPa6uIhOgjrx+xi7TKWznRzlJUS1fGJ/qAtF 9d0FGF5xX1sWjinSwK1vW13wBE1bCSaLs1XeM49mpfn4FoLCcS5bOUsSOBfGp9ZZ/dpP gcAyniUaykWCM/8AlsYWGK0uk+ZCc1XgWFsA3OPgyFVNIYR3K+VD6SwYdl+nY3w7o3L9 sgL8Gjk01ct4kzYuYkF525scN7XYKSM2VdgkI5gOCrmEqDg0jU6qgWNsbBxeXsetzOmN 424Lahg8TaudYrp1Ohk0YljqQgYkqj8Js8BflmGCozH/tSl/Fdut1zb/yrWj54NcOWYL Levg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693612360; x=1694217160; 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=4M4T9oKuv8pbgdqOgTCb0F93HmJB1LDIToIgnoaj87w=; b=UiFhYiRr2vy/u5rCwPXieJXdJvkka0S12rqtn+sm5mn7l2FfGIE+rzSCMSW9yhFzoz XuPuD5R1IDU+J34E1MTqnLNEq7Lvj9sy0hynj3jyWQabTdSM+nU3udrD8FSRuTdnmDj6 RsNUdnZXRqXXa3s35o9aHrTOgTaTmp7hmLBGlF5OqzavNsVztJVniLgDcLJPnuOk8ZvW a2UNIwxjZbQU1QCjLca0NeCcaITRwqS+vH427O0sbqvSHR69MrWuCGSiP/1SzodqjZku B+cD9HOSO1LlykLdZ34YyY+ugSQtNlNmIckXNAiSlL75iZPdMysE7rhbCUgSFofetJSa WNyA== X-Gm-Message-State: AOJu0YzR494rXdZeOyaGypi0AUVy3A/A/HmTdhuKPKJGoaZdEj8GM4v5 6YyBzm4evVbAcyZ0LbgQ+ERyY2ohN3p7oUBGiCY= X-Google-Smtp-Source: AGHT+IGZ9HpmzXrsHdEQW8FJmJVkNARZt9NRpzlqucGtzsatXRHcXucBqUgIc/NJ8FTq98xZb/tJUA== X-Received: by 2002:a17:902:c412:b0:1c0:77b8:bb10 with SMTP id k18-20020a170902c41200b001c077b8bb10mr6431642plk.10.1693612360475; Fri, 01 Sep 2023 16:52:40 -0700 (PDT) Received: from evan.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001bee782a1desm3499551plg.181.2023.09.01.16.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 16:52:40 -0700 (PDT) From: Evan Green To: libc-alpha@sourceware.org Subject: [PATCH v8 5/6] riscv: Add ifunc helper method to hwprobe.h Date: Fri, 1 Sep 2023 16:52:23 -0700 Message-Id: <20230901235224.3304592-6-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230901235224.3304592-1-evan@rivosinc.com> References: <20230901235224.3304592-1-evan@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , Evan Green , vineetg@rivosinc.com 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 --- (no changes since v7) 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 */