From: Evan Green <evan@rivosinc.com>
To: libc-alpha@sourceware.org
Cc: slewis@rivosinc.com, Florian Weimer <fweimer@redhat.com>,
vineetg@rivosinc.com, palmer@rivosinc.com,
Evan Green <evan@rivosinc.com>
Subject: [PATCH v8 5/6] riscv: Add ifunc helper method to hwprobe.h
Date: Fri, 1 Sep 2023 16:52:23 -0700 [thread overview]
Message-ID: <20230901235224.3304592-6-evan@rivosinc.com> (raw)
In-Reply-To: <20230901235224.3304592-1-evan@rivosinc.com>
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 <evan@rivosinc.com>
---
(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 <features.h>
#include <stddef.h>
+#include <errno.h>
#ifdef __has_include
# if __has_include (<asm/hwprobe.h>)
# include <asm/hwprobe.h>
@@ -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 */
--
2.34.1
next prev parent reply other threads:[~2023-09-01 23:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 23:52 [PATCH v8 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
2023-09-01 23:52 ` [PATCH v8 1/6] riscv: Add Linux hwprobe syscall support Evan Green
2023-09-01 23:52 ` [PATCH v8 2/6] riscv: Add hwprobe vdso call support Evan Green
2023-09-01 23:52 ` [PATCH v8 3/6] riscv: Add __riscv_hwprobe pointer to ifunc calls Evan Green
2023-09-29 18:21 ` Jessica Clarke
2023-09-29 19:40 ` Florian Weimer
2023-09-29 19:49 ` Jessica Clarke
2023-10-17 4:46 ` Fangrui Song
2023-09-01 23:52 ` [PATCH v8 4/6] riscv: Enable multi-arg ifunc resolvers Evan Green
2023-09-01 23:52 ` Evan Green [this message]
2023-09-01 23:52 ` [PATCH v8 6/6] riscv: Add and use alignment-ignorant memcpy Evan Green
2023-09-25 10:28 ` [PATCH v8 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Palmer Dabbelt
2023-09-26 2:24 ` enh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230901235224.3304592-6-evan@rivosinc.com \
--to=evan@rivosinc.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=palmer@rivosinc.com \
--cc=slewis@rivosinc.com \
--cc=vineetg@rivosinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).