[PATCH v2 3/3] target-info: Statically initialize target_arch

Richard Henderson posted 3 patches 5 days, 5 hours ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
[PATCH v2 3/3] target-info: Statically initialize target_arch
Posted by Richard Henderson 5 days, 5 hours ago
Use TARGET_ARCH and token pasting to initialize
target_arch from SYS_EMU_TARGET_*.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target-info-stub.c | 2 +-
 target-info.c      | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/target-info-stub.c b/target-info-stub.c
index 8392d81e8f..65220cc782 100644
--- a/target-info-stub.c
+++ b/target-info-stub.c
@@ -18,7 +18,7 @@ QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
 
 static const TargetInfo target_info_stub = {
     .target_name = TARGET_NAME,
-    .target_arch = SYS_EMU_TARGET__MAX,
+    .target_arch = glue(SYS_EMU_TARGET_, TARGET_ARCH),
     .long_bits = TARGET_LONG_BITS,
     .cpu_type = CPU_RESOLVING_TYPE,
     .machine_typename = TYPE_MACHINE,
diff --git a/target-info.c b/target-info.c
index 5a6d728252..a26532f660 100644
--- a/target-info.c
+++ b/target-info.c
@@ -24,13 +24,7 @@ unsigned target_long_bits(void)
 
 SysEmuTarget target_arch(void)
 {
-    SysEmuTarget arch = target_info()->target_arch;
-
-    if (arch == SYS_EMU_TARGET__MAX) {
-        arch = qapi_enum_parse(&SysEmuTarget_lookup, target_name(), -1,
-                               &error_abort);
-    }
-    return arch;
+    return target_info()->target_arch;
 }
 
 const char *target_cpu_type(void)
-- 
2.43.0
Re: [PATCH v2 3/3] target-info: Statically initialize target_arch
Posted by Philippe Mathieu-Daudé 4 days, 11 hours ago
On 5/2/26 04:06, Richard Henderson wrote:
> Use TARGET_ARCH and token pasting to initialize
> target_arch from SYS_EMU_TARGET_*.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target-info-stub.c | 2 +-
>   target-info.c      | 8 +-------
>   2 files changed, 2 insertions(+), 8 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Re: [PATCH v2 3/3] target-info: Statically initialize target_arch
Posted by Pierrick Bouvier 5 days, 2 hours ago
On 2/4/26 7:06 PM, Richard Henderson wrote:
> Use TARGET_ARCH and token pasting to initialize
> target_arch from SYS_EMU_TARGET_*.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target-info-stub.c | 2 +-
>   target-info.c      | 8 +-------
>   2 files changed, 2 insertions(+), 8 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>