On 8/5/25 01:14, Pierrick Bouvier wrote:
Add runtime helpers for target and config queries.
Note: This will be reimplemented later [1] using proper information in
TargetInfo. Meanwhile, just add a simple implementation.
[1]
https://patchew.org/QEMU/20250424222112.36194-1-philmd@linaro.org/20250424222112.36194-19-philmd@linaro.org/
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
meson.build | 2 +-
include/qemu/target-info.h | 14 +++++
target-info.c | 117 +++++++++++++++++++++++++++++++++++++
3 files changed, 132 insertions(+), 1 deletion(-)
+bool target_mips(void)
I know this is the same lowercase name, but maybe we could consider
directly using target_mips32() instead of keeping the technical debt
of having TARGET_MIPS defined for both 32 and 64-bit targets.
Thankfully we cleared that with recent targets (i.e. LoongArch or
RISC-V -- AVR is a bit different, since 8-bit AVR and AVR32 are
distinct architectures).
For x86 we often use 'x86' as any of (i386, x86_64, amd64), maybe
we can introduce target_x86() too.
+{
+#ifdef TARGET_MIPS
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_mips64(void)
+{
+#ifdef TARGET_MIPS64
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_loongarch64(void)
+{
+#ifdef TARGET_LOONGARCH64
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_riscv32(void)
+{
+#ifdef TARGET_RISCV32
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_riscv64(void)
+{
+#ifdef TARGET_RISCV64
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_ppc(void)
Ditto, target_ppc32()?
+{
+#ifdef TARGET_PPC
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_ppc64(void)
+{
+#ifdef TARGET_ppc64
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool target_has_kvm(void)
+{
+#ifdef CONFIG_KVM
+ return true;
+#else
+ return false;
+#endif
+}