[for-6.2,4/8] meson.build: Define QEMU_ARCH in config-target.h

Message ID 20210730105947.28215-5-peter.maydell@linaro.org
State Superseded
Headers show
Series
  • softmmu: Clean up arch_init.c
Related show

Commit Message

Peter Maydell July 30, 2021, 10:59 a.m.
Instead of using an ifdef ladder in arch_init.c (which we then have
to manually update every time we add or remove a target
architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO"
in the config-target.h file.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 meson.build         |  2 ++
 softmmu/arch_init.c | 41 -----------------------------------------
 2 files changed, 2 insertions(+), 41 deletions(-)

-- 
2.20.1

Comments

Philippe Mathieu-Daudé July 30, 2021, 1:19 p.m. | #1
On 7/30/21 12:59 PM, Peter Maydell wrote:
> Instead of using an ifdef ladder in arch_init.c (which we then have

> to manually update every time we add or remove a target

> architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO"

> in the config-target.h file.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  meson.build         |  2 ++

>  softmmu/arch_init.c | 41 -----------------------------------------

>  2 files changed, 2 insertions(+), 41 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Richard Henderson July 30, 2021, 6:43 p.m. | #2
On 7/30/21 12:59 AM, Peter Maydell wrote:
> Instead of using an ifdef ladder in arch_init.c (which we then have

> to manually update every time we add or remove a target

> architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO"

> in the config-target.h file.

> 

> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>

> ---

>   meson.build         |  2 ++

>   softmmu/arch_init.c | 41 -----------------------------------------

>   2 files changed, 2 insertions(+), 41 deletions(-)


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


r~

Patch

diff --git a/meson.build b/meson.build
index f2e148eaf98..861965c286b 100644
--- a/meson.build
+++ b/meson.build
@@ -1625,6 +1625,8 @@  foreach target : target_dirs
       config_target_data.set(k, v)
     endif
   endforeach
+  config_target_data.set('QEMU_ARCH',
+                         'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
   config_target_h += {target: configure_file(output: target + '-config-target.h',
                                                configuration: config_target_data)}
 
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 91cbf883e28..8919405c7b2 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -38,45 +38,4 @@  int graphic_height = 600;
 int graphic_depth = 32;
 #endif
 
-
-#if defined(TARGET_ALPHA)
-#define QEMU_ARCH QEMU_ARCH_ALPHA
-#elif defined(TARGET_ARM)
-#define QEMU_ARCH QEMU_ARCH_ARM
-#elif defined(TARGET_CRIS)
-#define QEMU_ARCH QEMU_ARCH_CRIS
-#elif defined(TARGET_HPPA)
-#define QEMU_ARCH QEMU_ARCH_HPPA
-#elif defined(TARGET_I386)
-#define QEMU_ARCH QEMU_ARCH_I386
-#elif defined(TARGET_M68K)
-#define QEMU_ARCH QEMU_ARCH_M68K
-#elif defined(TARGET_MICROBLAZE)
-#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
-#elif defined(TARGET_MIPS)
-#define QEMU_ARCH QEMU_ARCH_MIPS
-#elif defined(TARGET_NIOS2)
-#define QEMU_ARCH QEMU_ARCH_NIOS2
-#elif defined(TARGET_OPENRISC)
-#define QEMU_ARCH QEMU_ARCH_OPENRISC
-#elif defined(TARGET_PPC)
-#define QEMU_ARCH QEMU_ARCH_PPC
-#elif defined(TARGET_RISCV)
-#define QEMU_ARCH QEMU_ARCH_RISCV
-#elif defined(TARGET_RX)
-#define QEMU_ARCH QEMU_ARCH_RX
-#elif defined(TARGET_S390X)
-#define QEMU_ARCH QEMU_ARCH_S390X
-#elif defined(TARGET_SH4)
-#define QEMU_ARCH QEMU_ARCH_SH4
-#elif defined(TARGET_SPARC)
-#define QEMU_ARCH QEMU_ARCH_SPARC
-#elif defined(TARGET_TRICORE)
-#define QEMU_ARCH QEMU_ARCH_TRICORE
-#elif defined(TARGET_XTENSA)
-#define QEMU_ARCH QEMU_ARCH_XTENSA
-#elif defined(TARGET_AVR)
-#define QEMU_ARCH QEMU_ARCH_AVR
-#endif
-
 const uint32_t arch_type = QEMU_ARCH;