Re: [PATCH] exec: Rename target_words_bigendian() -> target_big_endian()

2025-04-25 Thread Philippe Mathieu-Daudé

On 17/4/25 23:00, Philippe Mathieu-Daudé wrote:

In commit 98ed8ecfc9d ("exec: introduce target_words_bigendian()
helper") target_words_bigendian() was matching the definition it
was depending on (TARGET_WORDS_BIGENDIAN). Later in commit
ee3eb3a7ce7 ("Replace TARGET_WORDS_BIGENDIAN") the definition was
renamed as TARGET_BIG_ENDIAN but we didn't update the helper.
Do it now mechanically using:

   $ sed -i -e s/target_words_bigendian/target_big_endian/g \
 $(git grep -wl target_words_bigendian)

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/exec/tswap.h | 12 ++--
  system/memory-internal.h |  2 +-
  cpu-target.c |  4 ++--
  hw/core/cpu-system.c |  2 +-
  hw/display/vga.c |  2 +-
  hw/virtio/virtio.c   |  2 +-
  system/memory.c  |  4 ++--
  system/qtest.c   |  2 +-
  8 files changed, 15 insertions(+), 15 deletions(-)


Patch queued, thanks.



Re: [PATCH] exec: Rename target_words_bigendian() -> target_big_endian()

2025-04-18 Thread Michael S. Tsirkin
On Thu, Apr 17, 2025 at 11:00:25PM +0200, Philippe Mathieu-Daudé wrote:
> In commit 98ed8ecfc9d ("exec: introduce target_words_bigendian()
> helper") target_words_bigendian() was matching the definition it
> was depending on (TARGET_WORDS_BIGENDIAN). Later in commit
> ee3eb3a7ce7 ("Replace TARGET_WORDS_BIGENDIAN") the definition was
> renamed as TARGET_BIG_ENDIAN but we didn't update the helper.
> Do it now mechanically using:
> 
>   $ sed -i -e s/target_words_bigendian/target_big_endian/g \
> $(git grep -wl target_words_bigendian)
> 
> Signed-off-by: Philippe Mathieu-Daudé 

Reviewed-by: Michael S. Tsirkin 

> ---
>  include/exec/tswap.h | 12 ++--
>  system/memory-internal.h |  2 +-
>  cpu-target.c |  4 ++--
>  hw/core/cpu-system.c |  2 +-
>  hw/display/vga.c |  2 +-
>  hw/virtio/virtio.c   |  2 +-
>  system/memory.c  |  4 ++--
>  system/qtest.c   |  2 +-
>  8 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/include/exec/tswap.h b/include/exec/tswap.h
> index 84060a49994..49511f26117 100644
> --- a/include/exec/tswap.h
> +++ b/include/exec/tswap.h
> @@ -11,15 +11,15 @@
>  #include "qemu/bswap.h"
>  
>  /**
> - * target_words_bigendian:
> + * target_big_endian:
>   * Returns true if the (default) endianness of the target is big endian,
>   * false otherwise. Common code should normally never need to know about the
>   * endianness of the target, so please do *not* use this function unless you
>   * know very well what you are doing!
>   */
> -bool target_words_bigendian(void);
> +bool target_big_endian(void);
>  #ifdef COMPILING_PER_TARGET
> -#define target_words_bigendian()  TARGET_BIG_ENDIAN
> +#define target_big_endian()   TARGET_BIG_ENDIAN
>  #endif
>  
>  /*
> @@ -29,7 +29,7 @@ bool target_words_bigendian(void);
>  #ifdef COMPILING_PER_TARGET
>  #define target_needs_bswap()  (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
>  #else
> -#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_words_bigendian())
> +#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_big_endian())
>  #endif /* COMPILING_PER_TARGET */
>  
>  static inline uint16_t tswap16(uint16_t s)
> @@ -83,7 +83,7 @@ static inline void tswap64s(uint64_t *s)
>  /* Return ld{word}_{le,be}_p following target endianness. */
>  #define LOAD_IMPL(word, args...)\
>  do {\
> -if (target_words_bigendian()) { \
> +if (target_big_endian()) {  \
>  return glue(glue(ld, word), _be_p)(args);   \
>  } else {\
>  return glue(glue(ld, word), _le_p)(args);   \
> @@ -120,7 +120,7 @@ static inline uint64_t ldn_p(const void *ptr, int sz)
>  /* Call st{word}_{le,be}_p following target endianness. */
>  #define STORE_IMPL(word, args...)   \
>  do {\
> -if (target_words_bigendian()) { \
> +if (target_big_endian()) {  \
>  glue(glue(st, word), _be_p)(args);  \
>  } else {\
>  glue(glue(st, word), _le_p)(args);  \
> diff --git a/system/memory-internal.h b/system/memory-internal.h
> index 085e81a9fe4..29717b3c58f 100644
> --- a/system/memory-internal.h
> +++ b/system/memory-internal.h
> @@ -45,7 +45,7 @@ static inline bool devend_big_endian(enum device_endian end)
>DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN);
>  
>  if (end == DEVICE_NATIVE_ENDIAN) {
> -return target_words_bigendian();
> +return target_big_endian();
>  }
>  return end == DEVICE_BIG_ENDIAN;
>  }
> diff --git a/cpu-target.c b/cpu-target.c
> index e018acbf71a..b5645ff0dbb 100644
> --- a/cpu-target.c
> +++ b/cpu-target.c
> @@ -86,8 +86,8 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
>  abort();
>  }
>  
> -#undef target_words_bigendian
> -bool target_words_bigendian(void)
> +#undef target_big_endian
> +bool target_big_endian(void)
>  {
>  return TARGET_BIG_ENDIAN;
>  }
> diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
> index 82b68b8927d..3c84176a0c5 100644
> --- a/hw/core/cpu-system.c
> +++ b/hw/core/cpu-system.c
> @@ -133,7 +133,7 @@ bool cpu_virtio_is_big_endian(CPUState *cpu)
>  if (cpu->cc->sysemu_ops->virtio_is_big_endian) {
>  return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu);
>  }
> -return target_words_bigendian();
> +return target_big_endian();
>  }
>  
>  GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
> diff --git a/hw/display/vga.c b/hw/display/vga.c
> index b01f67c65fb..20475ebbd31 100644
> --- a/hw/display/vga.c
> +++ b/hw/display/vga.c
> @@ -2264,7 +2264,7 @@ bool vga_common_init(VGACommonState *s, Object *obj, 
> Error **errp)
>   * into a device attribute set by the machine/platform to remove
>   * all target endian dependencies from this file.
>   */
> -s->default_endian_fb = target_wor

Re: [PATCH] exec: Rename target_words_bigendian() -> target_big_endian()

2025-04-17 Thread Pierrick Bouvier

On 4/17/25 14:00, Philippe Mathieu-Daudé wrote:

In commit 98ed8ecfc9d ("exec: introduce target_words_bigendian()
helper") target_words_bigendian() was matching the definition it
was depending on (TARGET_WORDS_BIGENDIAN). Later in commit
ee3eb3a7ce7 ("Replace TARGET_WORDS_BIGENDIAN") the definition was
renamed as TARGET_BIG_ENDIAN but we didn't update the helper.
Do it now mechanically using:

   $ sed -i -e s/target_words_bigendian/target_big_endian/g \
 $(git grep -wl target_words_bigendian)

Signed-off-by: Philippe Mathieu-Daudé 
---
  include/exec/tswap.h | 12 ++--
  system/memory-internal.h |  2 +-
  cpu-target.c |  4 ++--
  hw/core/cpu-system.c |  2 +-
  hw/display/vga.c |  2 +-
  hw/virtio/virtio.c   |  2 +-
  system/memory.c  |  4 ++--
  system/qtest.c   |  2 +-
  8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index 84060a49994..49511f26117 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -11,15 +11,15 @@
  #include "qemu/bswap.h"
  
  /**

- * target_words_bigendian:
+ * target_big_endian:
   * Returns true if the (default) endianness of the target is big endian,
   * false otherwise. Common code should normally never need to know about the
   * endianness of the target, so please do *not* use this function unless you
   * know very well what you are doing!
   */
-bool target_words_bigendian(void);
+bool target_big_endian(void);
  #ifdef COMPILING_PER_TARGET
-#define target_words_bigendian()  TARGET_BIG_ENDIAN
+#define target_big_endian()   TARGET_BIG_ENDIAN
  #endif
  
  /*

@@ -29,7 +29,7 @@ bool target_words_bigendian(void);
  #ifdef COMPILING_PER_TARGET
  #define target_needs_bswap()  (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
  #else
-#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_words_bigendian())
+#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_big_endian())
  #endif /* COMPILING_PER_TARGET */
  
  static inline uint16_t tswap16(uint16_t s)

@@ -83,7 +83,7 @@ static inline void tswap64s(uint64_t *s)
  /* Return ld{word}_{le,be}_p following target endianness. */
  #define LOAD_IMPL(word, args...)\
  do {\
-if (target_words_bigendian()) { \
+if (target_big_endian()) {  \
  return glue(glue(ld, word), _be_p)(args);   \
  } else {\
  return glue(glue(ld, word), _le_p)(args);   \
@@ -120,7 +120,7 @@ static inline uint64_t ldn_p(const void *ptr, int sz)
  /* Call st{word}_{le,be}_p following target endianness. */
  #define STORE_IMPL(word, args...)   \
  do {\
-if (target_words_bigendian()) { \
+if (target_big_endian()) {  \
  glue(glue(st, word), _be_p)(args);  \
  } else {\
  glue(glue(st, word), _le_p)(args);  \
diff --git a/system/memory-internal.h b/system/memory-internal.h
index 085e81a9fe4..29717b3c58f 100644
--- a/system/memory-internal.h
+++ b/system/memory-internal.h
@@ -45,7 +45,7 @@ static inline bool devend_big_endian(enum device_endian end)
DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN);
  
  if (end == DEVICE_NATIVE_ENDIAN) {

-return target_words_bigendian();
+return target_big_endian();
  }
  return end == DEVICE_BIG_ENDIAN;
  }
diff --git a/cpu-target.c b/cpu-target.c
index e018acbf71a..b5645ff0dbb 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -86,8 +86,8 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
  abort();
  }
  
-#undef target_words_bigendian

-bool target_words_bigendian(void)
+#undef target_big_endian
+bool target_big_endian(void)
  {
  return TARGET_BIG_ENDIAN;
  }
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 82b68b8927d..3c84176a0c5 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -133,7 +133,7 @@ bool cpu_virtio_is_big_endian(CPUState *cpu)
  if (cpu->cc->sysemu_ops->virtio_is_big_endian) {
  return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu);
  }
-return target_words_bigendian();
+return target_big_endian();
  }
  
  GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)

diff --git a/hw/display/vga.c b/hw/display/vga.c
index b01f67c65fb..20475ebbd31 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2264,7 +2264,7 @@ bool vga_common_init(VGACommonState *s, Object *obj, 
Error **errp)
   * into a device attribute set by the machine/platform to remove
   * all target endian dependencies from this file.
   */
-s->default_endian_fb = target_words_bigendian();
+s->default_endian_fb = target_big_endian();
  s->big_endian_fb = s->default_endian_fb;
  
  vga_dirty_log_start(s);

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 85110bce374..8fbf1716b88 10064

[PATCH] exec: Rename target_words_bigendian() -> target_big_endian()

2025-04-17 Thread Philippe Mathieu-Daudé
In commit 98ed8ecfc9d ("exec: introduce target_words_bigendian()
helper") target_words_bigendian() was matching the definition it
was depending on (TARGET_WORDS_BIGENDIAN). Later in commit
ee3eb3a7ce7 ("Replace TARGET_WORDS_BIGENDIAN") the definition was
renamed as TARGET_BIG_ENDIAN but we didn't update the helper.
Do it now mechanically using:

  $ sed -i -e s/target_words_bigendian/target_big_endian/g \
$(git grep -wl target_words_bigendian)

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/exec/tswap.h | 12 ++--
 system/memory-internal.h |  2 +-
 cpu-target.c |  4 ++--
 hw/core/cpu-system.c |  2 +-
 hw/display/vga.c |  2 +-
 hw/virtio/virtio.c   |  2 +-
 system/memory.c  |  4 ++--
 system/qtest.c   |  2 +-
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index 84060a49994..49511f26117 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -11,15 +11,15 @@
 #include "qemu/bswap.h"
 
 /**
- * target_words_bigendian:
+ * target_big_endian:
  * Returns true if the (default) endianness of the target is big endian,
  * false otherwise. Common code should normally never need to know about the
  * endianness of the target, so please do *not* use this function unless you
  * know very well what you are doing!
  */
-bool target_words_bigendian(void);
+bool target_big_endian(void);
 #ifdef COMPILING_PER_TARGET
-#define target_words_bigendian()  TARGET_BIG_ENDIAN
+#define target_big_endian()   TARGET_BIG_ENDIAN
 #endif
 
 /*
@@ -29,7 +29,7 @@ bool target_words_bigendian(void);
 #ifdef COMPILING_PER_TARGET
 #define target_needs_bswap()  (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
 #else
-#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_words_bigendian())
+#define target_needs_bswap()  (HOST_BIG_ENDIAN != target_big_endian())
 #endif /* COMPILING_PER_TARGET */
 
 static inline uint16_t tswap16(uint16_t s)
@@ -83,7 +83,7 @@ static inline void tswap64s(uint64_t *s)
 /* Return ld{word}_{le,be}_p following target endianness. */
 #define LOAD_IMPL(word, args...)\
 do {\
-if (target_words_bigendian()) { \
+if (target_big_endian()) {  \
 return glue(glue(ld, word), _be_p)(args);   \
 } else {\
 return glue(glue(ld, word), _le_p)(args);   \
@@ -120,7 +120,7 @@ static inline uint64_t ldn_p(const void *ptr, int sz)
 /* Call st{word}_{le,be}_p following target endianness. */
 #define STORE_IMPL(word, args...)   \
 do {\
-if (target_words_bigendian()) { \
+if (target_big_endian()) {  \
 glue(glue(st, word), _be_p)(args);  \
 } else {\
 glue(glue(st, word), _le_p)(args);  \
diff --git a/system/memory-internal.h b/system/memory-internal.h
index 085e81a9fe4..29717b3c58f 100644
--- a/system/memory-internal.h
+++ b/system/memory-internal.h
@@ -45,7 +45,7 @@ static inline bool devend_big_endian(enum device_endian end)
   DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN);
 
 if (end == DEVICE_NATIVE_ENDIAN) {
-return target_words_bigendian();
+return target_big_endian();
 }
 return end == DEVICE_BIG_ENDIAN;
 }
diff --git a/cpu-target.c b/cpu-target.c
index e018acbf71a..b5645ff0dbb 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -86,8 +86,8 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
 abort();
 }
 
-#undef target_words_bigendian
-bool target_words_bigendian(void)
+#undef target_big_endian
+bool target_big_endian(void)
 {
 return TARGET_BIG_ENDIAN;
 }
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c
index 82b68b8927d..3c84176a0c5 100644
--- a/hw/core/cpu-system.c
+++ b/hw/core/cpu-system.c
@@ -133,7 +133,7 @@ bool cpu_virtio_is_big_endian(CPUState *cpu)
 if (cpu->cc->sysemu_ops->virtio_is_big_endian) {
 return cpu->cc->sysemu_ops->virtio_is_big_endian(cpu);
 }
-return target_words_bigendian();
+return target_big_endian();
 }
 
 GuestPanicInformation *cpu_get_crash_info(CPUState *cpu)
diff --git a/hw/display/vga.c b/hw/display/vga.c
index b01f67c65fb..20475ebbd31 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2264,7 +2264,7 @@ bool vga_common_init(VGACommonState *s, Object *obj, 
Error **errp)
  * into a device attribute set by the machine/platform to remove
  * all target endian dependencies from this file.
  */
-s->default_endian_fb = target_words_bigendian();
+s->default_endian_fb = target_big_endian();
 s->big_endian_fb = s->default_endian_fb;
 
 vga_dirty_log_start(s);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 85110bce374..8fbf1716b88 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2248,7 +2248,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_