[PATCH 00/16] overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check

Philippe Mathieu-Daudé posted 16 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251010134226.72221-1-philmd@linaro.org
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Helge Deller <deller@gmx.de>, Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>, Dmitry Osipenko <dmitry.osipenko@collabora.com>, Stefano Garzarella <sgarzare@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Jason Wang <jasowang@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Paolo Bonzini <pbonzini@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
include/hw/virtio/virtio-access.h       |   6 +-
include/hw/virtio/virtio-gpu-bswap.h    |   6 +-
target/arm/cpu.h                        |   8 +-
target/arm/tcg/translate-a64.h          |   5 +-
disas/disas-host.c                      |   6 +-
hw/core/loader.c                        |   5 +-
hw/display/artist.c                     |  12 +-
hw/display/vga.c                        |  20 +-
hw/display/virtio-gpu-gl.c              |   8 +-
hw/display/virtio-gpu-rutabaga.c        |   8 +-
hw/virtio/vhost.c                       |   7 +-
linux-user/arm/nwfpe/double_cpdo.c      |  12 +-
linux-user/arm/nwfpe/fpa11_cpdt.c       |  77 +-
net/net.c                               |  14 +-
target/alpha/translate.c                |  11 +-
target/arm/tcg/sve_helper.c             |  10 +-
target/arm/tcg/translate-sve.c          |  22 +-
target/arm/tcg/translate-vfp.c          |   8 +-
target/arm/tcg/translate.c              |   6 +-
target/mips/tcg/msa_helper.c            | 889 ++++++++++++------------
target/ppc/arch_dump.c                  |   9 +-
target/ppc/int_helper.c                 |  28 +-
target/ppc/kvm.c                        |  25 +-
target/riscv/vector_helper.c            |  32 +-
target/s390x/tcg/translate.c            |   6 +-
target/sparc/vis_helper.c               |  18 +-
ui/vdagent.c                            |  16 +-
ui/vnc.c                                |   6 +-
util/bitmap.c                           |  19 +-
target/ppc/translate/vmx-impl.c.inc     |  14 +-
target/ppc/translate/vsx-impl.c.inc     |   6 +-
target/riscv/insn_trans/trans_rvv.c.inc |  16 +-
target/s390x/tcg/translate_vx.c.inc     |   6 +-
tcg/ppc/tcg-target.c.inc                |  24 +-
34 files changed, 656 insertions(+), 709 deletions(-)
[PATCH 00/16] overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Posted by Philippe Mathieu-Daudé 1 month ago
Replace compile-time #ifdef with a runtime check to ensure all code
paths are built and tested. This reduces build-time configuration
complexity and improves maintainability.

No functional change intended.

Philippe Mathieu-Daudé (16):
  linux-user/arm: Checkpatch style cleanups
  linux-user/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  ui: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  net: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  disas: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  hw/core/loader: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  hw/display: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/alpha: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/mips: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/riscv: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/s390x: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  target/sparc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
  util/bitmap: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check

 include/hw/virtio/virtio-access.h       |   6 +-
 include/hw/virtio/virtio-gpu-bswap.h    |   6 +-
 target/arm/cpu.h                        |   8 +-
 target/arm/tcg/translate-a64.h          |   5 +-
 disas/disas-host.c                      |   6 +-
 hw/core/loader.c                        |   5 +-
 hw/display/artist.c                     |  12 +-
 hw/display/vga.c                        |  20 +-
 hw/display/virtio-gpu-gl.c              |   8 +-
 hw/display/virtio-gpu-rutabaga.c        |   8 +-
 hw/virtio/vhost.c                       |   7 +-
 linux-user/arm/nwfpe/double_cpdo.c      |  12 +-
 linux-user/arm/nwfpe/fpa11_cpdt.c       |  77 +-
 net/net.c                               |  14 +-
 target/alpha/translate.c                |  11 +-
 target/arm/tcg/sve_helper.c             |  10 +-
 target/arm/tcg/translate-sve.c          |  22 +-
 target/arm/tcg/translate-vfp.c          |   8 +-
 target/arm/tcg/translate.c              |   6 +-
 target/mips/tcg/msa_helper.c            | 889 ++++++++++++------------
 target/ppc/arch_dump.c                  |   9 +-
 target/ppc/int_helper.c                 |  28 +-
 target/ppc/kvm.c                        |  25 +-
 target/riscv/vector_helper.c            |  32 +-
 target/s390x/tcg/translate.c            |   6 +-
 target/sparc/vis_helper.c               |  18 +-
 ui/vdagent.c                            |  16 +-
 ui/vnc.c                                |   6 +-
 util/bitmap.c                           |  19 +-
 target/ppc/translate/vmx-impl.c.inc     |  14 +-
 target/ppc/translate/vsx-impl.c.inc     |   6 +-
 target/riscv/insn_trans/trans_rvv.c.inc |  16 +-
 target/s390x/tcg/translate_vx.c.inc     |   6 +-
 tcg/ppc/tcg-target.c.inc                |  24 +-
 34 files changed, 656 insertions(+), 709 deletions(-)

-- 
2.51.0


Re: [PATCH 00/16] overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Posted by Paolo Bonzini 1 month ago
On 10/10/25 15:42, Philippe Mathieu-Daudé wrote:
> Replace compile-time #ifdef with a runtime check to ensure all code
> paths are built and tested. This reduces build-time configuration
> complexity and improves maintainability.
> 
> No functional change intended.

No need to repost (and I didn't review), but please change throughout 
the commit message to mention a *compile-time* if() check.  The code for 
the wrong endianness will not make it past compilation, and mentioning 
runtime checks left me wondering if you had mistaken HOST for TARGET.

Thanks,

Paolo

> Philippe Mathieu-Daudé (16):
>    linux-user/arm: Checkpatch style cleanups
>    linux-user/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    ui: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    net: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    disas: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    hw/core/loader: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    hw/display: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/alpha: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/mips: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/riscv: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/s390x: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    target/sparc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
>    util/bitmap: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
> 
>   include/hw/virtio/virtio-access.h       |   6 +-
>   include/hw/virtio/virtio-gpu-bswap.h    |   6 +-
>   target/arm/cpu.h                        |   8 +-
>   target/arm/tcg/translate-a64.h          |   5 +-
>   disas/disas-host.c                      |   6 +-
>   hw/core/loader.c                        |   5 +-
>   hw/display/artist.c                     |  12 +-
>   hw/display/vga.c                        |  20 +-
>   hw/display/virtio-gpu-gl.c              |   8 +-
>   hw/display/virtio-gpu-rutabaga.c        |   8 +-
>   hw/virtio/vhost.c                       |   7 +-
>   linux-user/arm/nwfpe/double_cpdo.c      |  12 +-
>   linux-user/arm/nwfpe/fpa11_cpdt.c       |  77 +-
>   net/net.c                               |  14 +-
>   target/alpha/translate.c                |  11 +-
>   target/arm/tcg/sve_helper.c             |  10 +-
>   target/arm/tcg/translate-sve.c          |  22 +-
>   target/arm/tcg/translate-vfp.c          |   8 +-
>   target/arm/tcg/translate.c              |   6 +-
>   target/mips/tcg/msa_helper.c            | 889 ++++++++++++------------
>   target/ppc/arch_dump.c                  |   9 +-
>   target/ppc/int_helper.c                 |  28 +-
>   target/ppc/kvm.c                        |  25 +-
>   target/riscv/vector_helper.c            |  32 +-
>   target/s390x/tcg/translate.c            |   6 +-
>   target/sparc/vis_helper.c               |  18 +-
>   ui/vdagent.c                            |  16 +-
>   ui/vnc.c                                |   6 +-
>   util/bitmap.c                           |  19 +-
>   target/ppc/translate/vmx-impl.c.inc     |  14 +-
>   target/ppc/translate/vsx-impl.c.inc     |   6 +-
>   target/riscv/insn_trans/trans_rvv.c.inc |  16 +-
>   target/s390x/tcg/translate_vx.c.inc     |   6 +-
>   tcg/ppc/tcg-target.c.inc                |  24 +-
>   34 files changed, 656 insertions(+), 709 deletions(-)
> 


Re: [PATCH 00/16] overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Posted by Philippe Mathieu-Daudé 1 month ago
On 10/10/25 15:51, Paolo Bonzini wrote:
> On 10/10/25 15:42, Philippe Mathieu-Daudé wrote:
>> Replace compile-time #ifdef with a runtime check to ensure all code
>> paths are built and tested. This reduces build-time configuration
>> complexity and improves maintainability.
>>
>> No functional change intended.
> 
> No need to repost (and I didn't review), but please change throughout 
> the commit message to mention a *compile-time* if() check.  The code for 
> the wrong endianness will not make it past compilation, and mentioning 
> runtime checks left me wondering if you had mistaken HOST for TARGET.

I want HOST, and hope the changes are correct: I meant to express the
code is elided by the compiler, indeed not at *runtime* 🤦 I'll reword
the commit description. Thanks for catching this.

> 
> Thanks,
> 
> Paolo


Re: [PATCH 00/16] overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Posted by Philippe Mathieu-Daudé 4 weeks, 1 day ago
On 10/10/25 16:37, Philippe Mathieu-Daudé wrote:
> On 10/10/25 15:51, Paolo Bonzini wrote:
>> On 10/10/25 15:42, Philippe Mathieu-Daudé wrote:
>>> Replace compile-time #ifdef with a runtime check to ensure all code
>>> paths are built and tested. This reduces build-time configuration
>>> complexity and improves maintainability.
>>>
>>> No functional change intended.
>>
>> No need to repost (and I didn't review), but please change throughout 
>> the commit message to mention a *compile-time* if() check.  The code 
>> for the wrong endianness will not make it past compilation, and 
>> mentioning runtime checks left me wondering if you had mistaken HOST 
>> for TARGET.
> 
> I want HOST, and hope the changes are correct: I meant to express the
> code is elided by the compiler, indeed not at *runtime* 🤦 I'll reword
> the commit description. Thanks for catching this.

What about:

   Replace preprocessor-time #ifdef with a compile-time check
   to ensure all code paths are built and tested. This reduces
   build-time configuration complexity and simplifies code
   maintainability.

?