On 21/5/26 10:19, Chao Liu wrote:
On Wed, May 20, 2026 at 03:12:58PM +0800, Anton Johansson via wrote:
Adds a helper function to tell if the binary is targeting riscv64 or
not.
Reviewed-by: Pierrick Bouvier <[email protected]>
Signed-off-by: Anton Johansson <[email protected]>
---
include/qemu/target-info.h | 7 +++++++
target-info.c | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index 23c997de54..6c5b714288 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -99,4 +99,11 @@ bool target_ppc64(void);
*/
bool target_s390x(void);
+/**
There’s one extra * character here; otherwise LGTM.
This is the Javadoc tag which is also used by C tools such doxygen:
https://www.doxygen.nl/manual/docblocks.html#cppblock
We use sphinx with a kerneldoc.py plugin which understands it:
https://www.kernel.org/doc/Documentation/doc-guide/kernel-doc.rst
i.e. https://www.qemu.org/docs/master/devel/index-api.html
Reviewed-by: Chao Liu <[email protected]>
Thanks,
Chao
+ * target_riscv64:
+ *
+ * Returns whether the target architecture is riscv64
+ */
+bool target_riscv64(void);
+
#endif
diff --git a/target-info.c b/target-info.c
index 28c458fc7a..04c69c41f8 100644
--- a/target-info.c
+++ b/target-info.c
@@ -93,3 +93,8 @@ bool target_s390x(void)
{
return target_arch() == SYS_EMU_TARGET_S390X;
}
+
+bool target_riscv64(void)
+{
+ return target_arch() == SYS_EMU_TARGET_RISCV64;
+}
--
2.52.0