aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-07-08 23:53:16 +0200
committerMichael S. Tsirkin <mst@redhat.com>2025-07-15 02:56:39 -0400
commit749c21cf6d8ff8eff094137c4ca1298c8f714066 (patch)
tree41e9945f5ef04da414ba2fe578dba6a54219f09f
parenta37aec2e7d8f7191d29c700629850da5057e446b (diff)
downloadqemu-749c21cf6d8ff8eff094137c4ca1298c8f714066.zip
qemu-749c21cf6d8ff8eff094137c4ca1298c8f714066.tar.gz
qemu-749c21cf6d8ff8eff094137c4ca1298c8f714066.tar.bz2
qemu: Convert target_words_bigendian() to TargetInfo API
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250708215320.70426-6-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--cpu-target.c7
-rw-r--r--hw/core/cpu-system.c2
-rw-r--r--hw/display/vga.c2
-rw-r--r--hw/virtio/virtio.c2
-rw-r--r--include/exec/tswap.h13
-rw-r--r--include/qemu/target-info.h12
-rw-r--r--system/memory.c1
-rw-r--r--system/qtest.c1
-rw-r--r--target-info.c5
9 files changed, 23 insertions, 22 deletions
diff --git a/cpu-target.c b/cpu-target.c
index 1c90a30..20db5ff 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -22,7 +22,6 @@
#include "system/accel-ops.h"
#include "system/cpus.h"
#include "exec/cpu-common.h"
-#include "exec/tswap.h"
#include "exec/replay-core.h"
#include "exec/log.h"
#include "hw/core/cpu.h"
@@ -85,9 +84,3 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
#endif
abort();
}
-
-#undef target_big_endian
-bool target_big_endian(void)
-{
- return TARGET_BIG_ENDIAN;
-}
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 3c84176..a975405 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -24,7 +24,7 @@
#include "exec/cputlb.h"
#include "system/memory.h"
#include "exec/tb-flush.h"
-#include "exec/tswap.h"
+#include "qemu/target-info.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
#include "hw/core/sysemu-cpu-ops.h"
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 20475eb..90b89cf 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -26,7 +26,7 @@
#include "qemu/units.h"
#include "system/reset.h"
#include "qapi/error.h"
-#include "exec/tswap.h"
+#include "qemu/target-info.h"
#include "hw/display/vga.h"
#include "hw/i386/x86.h"
#include "hw/pci/pci.h"
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 82a285a..0f4d280 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -20,7 +20,7 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
-#include "exec/tswap.h"
+#include "qemu/target-info.h"
#include "qom/object_interfaces.h"
#include "hw/core/cpu.h"
#include "hw/virtio/virtio.h"
diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index 49511f2..55ffa63 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -9,18 +9,7 @@
#define TSWAP_H
#include "qemu/bswap.h"
-
-/**
- * target_big_endian:
- * Returns true if the (default) endianness of the target is big endian,
- * false otherwise. Common code should normally never need to know about the
- * endianness of the target, so please do *not* use this function unless you
- * know very well what you are doing!
- */
-bool target_big_endian(void);
-#ifdef COMPILING_PER_TARGET
-#define target_big_endian() TARGET_BIG_ENDIAN
-#endif
+#include "qemu/target-info.h"
/*
* If we're in target-specific code, we can hard-code the swapping
diff --git a/include/qemu/target-info.h b/include/qemu/target-info.h
index dde0e7d..abcf25d 100644
--- a/include/qemu/target-info.h
+++ b/include/qemu/target-info.h
@@ -38,4 +38,16 @@ const char *target_machine_typename(void);
*/
const char *target_cpu_type(void);
+/**
+ * target_big_endian:
+ *
+ * Returns: %true if the (default) endianness of the target is big endian,
+ * %false otherwise.
+ *
+ * Common code should normally never need to know about the endianness of
+ * the target, so please do *not* use this function unless you know very
+ * well what you are doing!
+ */
+bool target_big_endian(void);
+
#endif
diff --git a/system/memory.c b/system/memory.c
index e8d9b15..38da62f 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -22,6 +22,7 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/qemu-print.h"
+#include "qemu/target-info.h"
#include "qom/object.h"
#include "trace.h"
#include "system/ram_addr.h"
diff --git a/system/qtest.c b/system/qtest.c
index 301b03b..fa42c9f 100644
--- a/system/qtest.c
+++ b/system/qtest.c
@@ -29,6 +29,7 @@
#include "qemu/error-report.h"
#include "qemu/module.h"
#include "qemu/cutils.h"
+#include "qemu/target-info.h"
#include "qom/object_interfaces.h"
#define MAX_IRQ 256
diff --git a/target-info.c b/target-info.c
index a756c07..3110ab3 100644
--- a/target-info.c
+++ b/target-info.c
@@ -47,3 +47,8 @@ EndianMode target_endian_mode(void)
{
return target_info()->endianness;
}
+
+bool target_big_endian(void)
+{
+ return target_endian_mode() == ENDIAN_MODE_BIG;
+}