Re: [PATCH] exec: Rename NEED_CPU_H -> CONFIG_TARGET

2022-12-17 Thread Peter Maydell
On Fri, 16 Dec 2022 at 22:09, Philippe Mathieu-Daudé  wrote:
>
> 'NEED_CPU_H' guard target-specific code; it is defined by meson
> altogether with the 'CONFIG_TARGET' definition. Since the latter
> name is more meaningful, directly use it.
>
> Inspired-by: Peter Maydell 
> Signed-off-by: Philippe Mathieu-Daudé 

This feels to me like it's overloading the meaning of CONFIG_TARGET,
which at the moment is "the string which names the header file
with target-specific config definitions". I think I'd rather
we just renamed NEED_CPU_H to something a bit clearer, like
perhaps COMPILING_PER_TARGET (better suggestions welcome).

thanks
-- PMM



[PATCH] exec: Rename NEED_CPU_H -> CONFIG_TARGET

2022-12-16 Thread Philippe Mathieu-Daudé
'NEED_CPU_H' guard target-specific code; it is defined by meson
altogether with the 'CONFIG_TARGET' definition. Since the latter
name is more meaningful, directly use it.

Inspired-by: Peter Maydell 
Signed-off-by: Philippe Mathieu-Daudé 
---
Based-on: <20221216220738.7355-1-phi...@linaro.org>
  sysemu/kvm: Header cleanups around "cpu.h"
Based-on: <20221216220158.6317-1-phi...@linaro.org>
  target/i386: Header cleanups around "cpu.h"
---
 include/disas/disas.h | 2 +-
 include/exec/cpu-defs.h   | 2 +-
 include/exec/gdbstub.h| 4 ++--
 include/exec/helper-head.h| 4 ++--
 include/exec/memop.h  | 6 +++---
 include/exec/memory.h | 4 ++--
 include/hw/core/cpu.h | 4 ++--
 include/hw/core/tcg-cpu-ops.h | 4 ++--
 include/qemu/osdep.h  | 4 ++--
 include/sysemu/hax.h  | 4 ++--
 include/sysemu/hvf.h  | 4 ++--
 include/sysemu/kvm.h  | 8 
 include/sysemu/nvmm.h | 4 ++--
 include/sysemu/whpx.h | 4 ++--
 include/sysemu/xen.h  | 4 ++--
 meson.build   | 6 ++
 scripts/analyze-inclusions| 6 +++---
 target/arm/kvm-consts.h   | 2 +-
 18 files changed, 37 insertions(+), 39 deletions(-)

diff --git a/include/disas/disas.h b/include/disas/disas.h
index d363e95ede..1f6706a374 100644
--- a/include/disas/disas.h
+++ b/include/disas/disas.h
@@ -3,7 +3,7 @@
 
 #include "exec/hwaddr.h"
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 #include "cpu.h"
 
 /* Disassemble this for me please... (debugging). */
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 21309cf567..9775634ff6 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -19,7 +19,7 @@
 #ifndef CPU_DEFS_H
 #define CPU_DEFS_H
 
-#ifndef NEED_CPU_H
+#ifndef CONFIG_TARGET
 #error cpu.h included from common code
 #endif
 
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index f667014888..49f63d3c50 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -71,7 +71,7 @@ struct gdb_timeval {
   uint64_t tv_usec;   /* microsecond */
 } QEMU_PACKED;
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 #include "cpu.h"
 
 typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err);
@@ -214,7 +214,7 @@ static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, 
int len)
 #define ldtul_p(addr) ldl_p(addr)
 #endif
 
-#endif /* NEED_CPU_H */
+#endif /* CONFIG_TARGET */
 
 /**
  * gdbserver_start: start the gdb server
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
index e242fed46e..584b120312 100644
--- a/include/exec/helper-head.h
+++ b/include/exec/helper-head.h
@@ -49,7 +49,7 @@
 #define dh_ctype_noreturn G_NORETURN void
 #define dh_ctype(t) dh_ctype_##t
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 # ifdef TARGET_LONG_BITS
 #  if TARGET_LONG_BITS == 32
 #   define dh_alias_tl i32
@@ -63,7 +63,7 @@
 # define dh_alias_env ptr
 # define dh_ctype_env CPUArchState *
 # define dh_typecode_env dh_typecode_ptr
-#endif
+#endif /* CONFIG_TARGET */
 
 /* We can't use glue() here because it falls foul of C preprocessor
recursive expansion rules.  */
diff --git a/include/exec/memop.h b/include/exec/memop.h
index 25d027434a..ebf6c5f69d 100644
--- a/include/exec/memop.h
+++ b/include/exec/memop.h
@@ -35,7 +35,7 @@ typedef enum MemOp {
 MO_LE= 0,
 MO_BE= MO_BSWAP,
 #endif
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 #if TARGET_BIG_ENDIAN
 MO_TE= MO_BE,
 #else
@@ -65,7 +65,7 @@ typedef enum MemOp {
  */
 MO_ASHIFT = 5,
 MO_AMASK = 0x7 << MO_ASHIFT,
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 #ifdef TARGET_ALIGNED_ONLY
 MO_ALIGN = 0,
 MO_UNALN = MO_AMASK,
@@ -107,7 +107,7 @@ typedef enum MemOp {
 MO_BESL  = MO_BE | MO_SL,
 MO_BESQ  = MO_BE | MO_SQ,
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 MO_TEUW  = MO_TE | MO_UW,
 MO_TEUL  = MO_TE | MO_UL,
 MO_TEUQ  = MO_TE | MO_UQ,
diff --git a/include/exec/memory.h b/include/exec/memory.h
index c37ffdbcd1..2d1fd6e475 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2938,7 +2938,7 @@ address_space_write_cached(MemoryRegionCache *cache, 
hwaddr addr,
 MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
   uint8_t c, hwaddr len, MemTxAttrs attrs);
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 /* enum device_endian to MemOp.  */
 static inline MemOp devend_memop(enum device_endian end)
 {
@@ -2956,7 +2956,7 @@ static inline MemOp devend_memop(enum device_endian end)
 return (end == non_host_endianness) ? MO_BSWAP : 0;
 #endif
 }
-#endif
+#endif /* CONFIG_TARGET */
 
 /*
  * Inhibit technologies that require discarding of pages in RAM blocks, e.g.,
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index bc3229ae13..5ab6244bc8 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1044,7 +1044,7 @@ bool target_words_bigendian(void);
 
 void page_size_init(void);
 
-#ifdef NEED_CPU_H
+#ifdef CONFIG_TARGET
 
 #ifdef