From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
qemu-riscv@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH-for-10.1 RESEND v8 4/8] qemu/target-info: Add target_endian_mode()
Date: Tue, 8 Jul 2025 23:53:15 +0200 [thread overview]
Message-ID: <20250708215320.70426-5-philmd@linaro.org> (raw)
In-Reply-To: <20250708215320.70426-1-philmd@linaro.org>
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>
---
include/qemu/target-info-impl.h | 2 ++
include/qemu/target-info-qapi.h | 8 ++++++++
target-info-stub.c | 1 +
target-info.c | 5 +++++
4 files changed, 16 insertions(+)
diff --git a/include/qemu/target-info-impl.h b/include/qemu/target-info-impl.h
index a8b34d150ab..17887f64e26 100644
--- a/include/qemu/target-info-impl.h
+++ b/include/qemu/target-info-impl.h
@@ -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;
/**
diff --git a/include/qemu/target-info-qapi.h b/include/qemu/target-info-qapi.h
index a337c867bfb..d5ce0523238 100644
--- a/include/qemu/target-info-qapi.h
+++ b/include/qemu/target-info-qapi.h
@@ -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"
/**
@@ -18,4 +19,11 @@
*/
SysEmuTarget target_arch(void);
+/**
+ * target_endian_mode:
+ *
+ * Returns: QAPI EndianMode enum (e.g. ENDIAN_MODE_LITTLE).
+ */
+EndianMode target_endian_mode(void);
+
#endif
diff --git a/target-info-stub.c b/target-info-stub.c
index 2e4407ff04b..ca0caa3686c 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -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)
diff --git a/target-info.c b/target-info.c
index 8e29553b4ef..a756c0714c4 100644
--- a/target-info.c
+++ b/target-info.c
@@ -42,3 +42,8 @@ const char *target_machine_typename(void)
{
return target_info()->machine_typename;
}
+
+EndianMode target_endian_mode(void)
+{
+ return target_info()->endianness;
+}
--
2.49.0
next prev parent reply other threads:[~2025-07-08 22:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 21:53 [PATCH-for-10.1 RESEND v8 0/8] target-info: Add more API for VirtIO cleanups Philippe Mathieu-Daudé
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 1/8] target/qmp: Use target_cpu_type() Philippe Mathieu-Daudé
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 2/8] qemu/target-info: Factor target_arch() out Philippe Mathieu-Daudé
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 3/8] qemu/target-info: Add %target_arch field to TargetInfo Philippe Mathieu-Daudé
2025-07-08 21:53 ` Philippe Mathieu-Daudé [this message]
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 5/8] qemu: Convert target_words_bigendian() to TargetInfo API Philippe Mathieu-Daudé
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 6/8] gdbstub/helpers: Replace TARGET_BIG_ENDIAN -> target_big_endian() Philippe Mathieu-Daudé
2025-07-09 6:33 ` Manos Pitsidianakis
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 7/8] qemu: Declare all load/store helper in 'qemu/bswap.h' Philippe Mathieu-Daudé
2025-07-08 21:53 ` [PATCH-for-10.1 RESEND v8 8/8] hw/virtio: Build various files once Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250708215320.70426-5-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=manos.pitsidianakis@linaro.org \
--cc=mst@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).