From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id A043B3861003 for ; Wed, 13 Dec 2023 21:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A043B3861003 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A043B3861003 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702501931; cv=none; b=dww1Qewmhty65c7R1hQ8rnuMjLfnMLNYplF/sahzRPMTtdotjFv+FnLNYK9ZxZ4jfzaMZCMPklnxtcN0vmzNMvdQ1IORFsguSa80toDYbQ6ktVwK2TKXSKNcsaMLjaQAmwGcacH36tKSO02YXG/fnnOgzduo94dX32/inzFwUDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702501931; c=relaxed/simple; bh=z1vJHZCylR7gWswaX1YedLgXlnv8wJeHQ6njXQLNraQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=V7xgjymTF762LwtvvrFxUag85CieU3CLyi5tRdRio4BEagfeKpW06cMqmc+GGiW3+tLr4ekPvdogi2/XDIRhvfMcz8me22OiLkeZCxwH09UMDEfHm4Oe8dnYAq471XIzWuhygO+yGAFDvznTO4G93dg9I8SXC6CHcEyHXy3zFlY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-59148c1ad35so1066871eaf.2 for ; Wed, 13 Dec 2023 13:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1702501928; x=1703106728; 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=a55kv/01G2tHxlqkOGuuQIyeV/sMfhNPjRYqXB5gRis=; b=qr7qHVoA4q7Q/MpX9vgttbe0INZCesDYXgRmM223yIWgb4sEsBeY0t4TYZxC79G6NU h9Jwk5TZ4UnffHst+SngHx5em9a18/eVUyzzPFPAgc/Wh1q/jnXV+HfDT9ysSVGeo2Xi RDeI/eFbeNqa5pFZGMvESbnvcXqek61pqVa7HCKb5j+taFq10DrwJ1aLg288hNtrlC0F 1FiVJRdoXgbeKZJBvX2R4IPynmrlZlPUU8ibGGLlxpSorKoodNZhY/H9NUJf3opr+RWS aU3Lo0b1jbGQUW9ZDMYXDh2V1jrrWMQlNHI3GVK8yIoDYC+Zd6/z4CUh/tEYFH+SdYyv IfGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702501928; x=1703106728; 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=a55kv/01G2tHxlqkOGuuQIyeV/sMfhNPjRYqXB5gRis=; b=TNbfx4i538jMZM1osucbxrqchZuscZXQJV9u+W+6AKKC1NYhHahRyDQiXI1aV/0+dO NJWIihjc243nFIDhpFs4vne2vrIpNkPXvvakCSGYiKpOub42hIQyKs+eSHMDbg6r952c iGqBzLxuKvZtg3MBr4C2ev3QyQulj4KRQHDR1UMd7dOEE0Y+j0SiKA2E0fs4K8ZopcKn 0YvMvr8flB9Vv0CtAy2noTrg59KH51BTj0bOXZLqLTEAmKi0xckqMf1vJop1b25q/8Mu vkqsm9BG0IeOLPBxPioT0CYOhfARQX0dhuwCPOZ3LBAj89/nsyhRZlYnnGrP1RUuyXjI sqhA== X-Gm-Message-State: AOJu0YwTvfD0UMHLzORjYpuXoxMTolvNBryfL50W9lPjIP170DsPSmeo H8ITjYgcSkERtvYA5FtW9mSrw6huLOGJZgIgpjM= X-Google-Smtp-Source: AGHT+IHU2UnV+dchdSkIDr2peFQ4aJt6rri3MKVWADDkRbqFd0dGRwsToqJjH8lJUUOHLjR0hr7Img== X-Received: by 2002:a4a:9891:0:b0:590:f911:42ef with SMTP id a17-20020a4a9891000000b00590f91142efmr3590756ooj.18.1702501928232; Wed, 13 Dec 2023 13:12:08 -0800 (PST) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id c15-20020a4a380f000000b0058d1de21893sm3223109ooa.24.2023.12.13.13.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 13:12:07 -0800 (PST) From: Evan Green To: libc-alpha@sourceware.org Cc: vineetg@rivosinc.com, slewis@rivosinc.com, palmer@rivosinc.com, Florian Weimer , Evan Green Subject: [PATCH v10 6/7] riscv: Add ifunc helper method to hwprobe.h Date: Wed, 13 Dec 2023 13:11:41 -0800 Message-Id: <20231213211142.1543025-7-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213211142.1543025-1-evan@rivosinc.com> References: <20231213211142.1543025-1-evan@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 v10: - Avoid implicit comparisons (Adhemerval) Changes in v9: - Use __inline rather than inline so c89 compiles (build-many-glibcs) Changes in v7: - Introduced static inline helper (Richard) sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h index c4e3927667..d85d49cd73 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 @@ -81,4 +82,28 @@ 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 == NULL) + return ENOSYS; + + pair.key = key; + rc = hwprobe_func (&pair, 1, 0, NULL, 0); + if (rc != 0) + return rc; + + if (pair.key < 0) + return ENOENT; + + *value = pair.value; + return 0; +} + #endif /* sys/hwprobe.h */ -- 2.34.1