]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qemu/target-info: Add target_endian_mode()
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 8 Jul 2025 21:53:15 +0000 (23:53 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 15 Jul 2025 06:56:39 +0000 (02:56 -0400)
target_endian_mode() returns the default endianness (QAPI type)
of a target.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250708215320.70426-5-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
include/qemu/target-info-impl.h
include/qemu/target-info-qapi.h
target-info-stub.c
target-info.c

index a8b34d150ab2c94f9c1d25523936382e02f5be4f..17887f64e26a49622d1a10623e390e5af4a7b0ff 100644 (file)
@@ -22,6 +22,8 @@ typedef struct TargetInfo {
     const char *cpu_type;
     /* QOM typename machines for this binary must implement */
     const char *machine_typename;
+    /* related to TARGET_BIG_ENDIAN definition */
+    EndianMode endianness;
 } TargetInfo;
 
 /**
index a337c867bfbb4fabf4d6cb4d9a94c1e4119f882c..d5ce05232388c8b863416963aa7a86c691b9bf7a 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef QEMU_TARGET_INFO_EXTRA_H
 #define QEMU_TARGET_INFO_EXTRA_H
 
+#include "qapi/qapi-types-common.h"
 #include "qapi/qapi-types-machine.h"
 
 /**
  */
 SysEmuTarget target_arch(void);
 
+/**
+ * target_endian_mode:
+ *
+ * Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
+ */
+EndianMode target_endian_mode(void);
+
 #endif
index 2e4407ff04b9a380a1215db36ae66ff785415f40..ca0caa3686c3a9e60fa9dd16ddb68a76f8615a20 100644 (file)
@@ -18,6 +18,7 @@ static const TargetInfo target_info_stub = {
     .long_bits = TARGET_LONG_BITS,
     .cpu_type = CPU_RESOLVING_TYPE,
     .machine_typename = TYPE_MACHINE,
+    .endianness = TARGET_BIG_ENDIAN ? ENDIAN_MODE_BIG : ENDIAN_MODE_LITTLE,
 };
 
 const TargetInfo *target_info(void)
index 8e29553b4eff0bf3e07887f9bb1ee99c0a4771d5..a756c0714c4b3f710aa1e9f9c97e2772523de67b 100644 (file)
@@ -42,3 +42,8 @@ const char *target_machine_typename(void)
 {
     return target_info()->machine_typename;
 }
+
+EndianMode target_endian_mode(void)
+{
+    return target_info()->endianness;
+}