diff mbox series

[8/8] hw/core/cpu: Expose cpu_is_big_endian() method

Message ID 20241004162118.84570-9-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series hw/core/cpu: Expose cpu_is_big_endian() method | expand

Commit Message

Philippe Mathieu-Daudé Oct. 4, 2024, 4:21 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/cpu.h | 8 ++++++++
 hw/core/cpu-common.c  | 7 +++++++
 2 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 22ef7a44e86..2550bc98dee 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -608,6 +608,14 @@  extern __thread CPUState *current_cpu;
 extern bool mttcg_enabled;
 #define qemu_tcg_mttcg_enabled() (mttcg_enabled)
 
+/**
+ * cpu_is_big_endian:
+ * @cpu: The CPU whose state is to be inspected.
+ *
+ * Returns: %true if the CPU runs in big endianness, %false otherwise.
+ */
+bool cpu_is_big_endian(CPUState *cpu);
+
 /**
  * cpu_paging_enabled:
  * @cpu: The CPU whose state is to be inspected.
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index aa5ea9761e4..277c4ee6720 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -66,6 +66,13 @@  CPUState *cpu_create(const char *typename)
     return cpu;
 }
 
+bool cpu_is_big_endian(CPUState *cpu)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    return cc->is_big_endian(cpu);
+}
+
 /* Resetting the IRQ comes from across the code base so we take the
  * BQL here if we need to.  cpu_interrupt assumes it is held.*/
 void cpu_reset_interrupt(CPUState *cpu, int mask)