Re: [PATCH 10/27] Replace config-time define HOST_WORDS_BIGENDIAN

Halil Pasic
2022-03-16T11:37:06Z

On Wed, 16 Mar 2022 13:53:07 +0400
marcandre.lureau@redhat.com wrote:

> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Replace a config-time define with a compile time condition
> define (compatible with clang and gcc) that must be declared prior to
> its usage. This avoids having a global configure time define, but also
> prevents from bad usage, if the config header wasn't included before.
>
> This can help to make some code independent from qemu too.
>
> gcc supports __BYTE_ORDER__ from about 4.6 and clang from 3.2.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

LGTM

For the s390x parts I'm involved in:
Acked-by: Halil Pasic <pasic@linux.ibm.com>

[..]

> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -34,13 +34,13 @@
>
> /* some important defines:
> *
> - * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and
> + * HOST_BIG_ENDIAN : whether the host cpu is big endian and
> * otherwise little endian.
> *
> * TARGET_WORDS_BIGENDIAN : same for target cpu
> */

This comment does not seem spot on any more. BTW would it make sense
to replace TARGET_WORDS_BIGENDIAN with TARGET_BIG_ENDIAN as well. I
believe the bad usage argument applies equally to both, and IMHO we
should keep the both consistent naming and usage wise.

>
> -#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
> +#if HOST_BIG_ENDIAN != defined(TARGET_WORDS_BIGENDIAN)
> #define BSWAP_NEEDED
> #endif
>

[..]