diff mbox series

[RFC,06/11] include: Declare target_name() in common "qemu/arch_info.h"

Message ID 20250305005225.95051-7-philmd@linaro.org
State New
Headers show
Series qemu: Remove TARGET_NAME definition | expand

Commit Message

Philippe Mathieu-Daudé March 5, 2025, 12:52 a.m. UTC
No need to include the huge "hw/core/cpu.h" header to
get a simple prototype declaration such target_name().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/cpu.h      | 2 --
 include/qemu/arch_info.h   | 2 ++
 arch_info-target.c         | 5 +++++
 cpu-target.c               | 5 -----
 hw/core/machine-qmp-cmds.c | 1 +
 system/vl.c                | 1 -
 6 files changed, 8 insertions(+), 8 deletions(-)

Comments

Richard Henderson March 5, 2025, 2:44 a.m. UTC | #1
On 3/4/25 16:52, Philippe Mathieu-Daudé wrote:
> No need to include the huge "hw/core/cpu.h" header to
> get a simple prototype declaration such target_name().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/core/cpu.h      | 2 --
>   include/qemu/arch_info.h   | 2 ++
>   arch_info-target.c         | 5 +++++
>   cpu-target.c               | 5 -----
>   hw/core/machine-qmp-cmds.c | 1 +
>   system/vl.c                | 1 -
>   6 files changed, 8 insertions(+), 8 deletions(-)

You should mention moving the function as well.  Otherwise,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
diff mbox series

Patch

diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 5d11d26556a..4f538a8f96d 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1162,8 +1162,6 @@  bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
 void cpu_exec_unrealizefn(CPUState *cpu);
 void cpu_exec_reset_hold(CPUState *cpu);
 
-const char *target_name(void);
-
 #ifdef COMPILING_PER_TARGET
 
 #ifndef CONFIG_USER_ONLY
diff --git a/include/qemu/arch_info.h b/include/qemu/arch_info.h
index 3cb95926e27..613dc2037db 100644
--- a/include/qemu/arch_info.h
+++ b/include/qemu/arch_info.h
@@ -46,6 +46,8 @@  typedef enum QemuArchBit {
 #define QEMU_ARCH_LOONGARCH     BIT(QEMU_ARCH_BIT_LOONGARCH)
 #define QEMU_ARCH_ALL           -1
 
+const char *target_name(void);
+
 bool qemu_arch_available(unsigned qemu_arch_mask);
 
 #endif
diff --git a/arch_info-target.c b/arch_info-target.c
index 6c11c73feb9..61007415b30 100644
--- a/arch_info-target.c
+++ b/arch_info-target.c
@@ -24,6 +24,11 @@ 
 #include "qemu/osdep.h"
 #include "qemu/arch_info.h"
 
+const char *target_name(void)
+{
+    return TARGET_NAME;
+}
+
 bool qemu_arch_available(unsigned qemu_arch_mask)
 {
     return qemu_arch_mask & BIT(QEMU_ARCH_BIT);
diff --git a/cpu-target.c b/cpu-target.c
index f7e17a650c0..1177e93c444 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -158,8 +158,3 @@  bool target_words_bigendian(void)
 {
     return TARGET_BIG_ENDIAN;
 }
-
-const char *target_name(void)
-{
-    return TARGET_NAME;
-}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 3130c5cd456..3bf280cef16 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -19,6 +19,7 @@ 
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/type-helpers.h"
 #include "qemu/uuid.h"
+#include "qemu/arch_info.h"
 #include "qom/qom-qobject.h"
 #include "system/hostmem.h"
 #include "system/hw_accel.h"
diff --git a/system/vl.c b/system/vl.c
index e96c72e5400..a41ba4a2d5f 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -80,7 +80,6 @@ 
 #include "hw/block/block.h"
 #include "hw/i386/x86.h"
 #include "hw/i386/pc.h"
-#include "hw/core/cpu.h"
 #include "migration/cpr.h"
 #include "migration/misc.h"
 #include "migration/snapshot.h"