[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/8] qemu/bswap: Replace bswapXXs() by compiler __builtin_
From: |
Thomas Huth |
Subject: |
Re: [PATCH v2 3/8] qemu/bswap: Replace bswapXXs() by compiler __builtin_bswap() |
Date: |
Mon, 28 Sep 2020 19:29:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
On 28/09/2020 15.19, Philippe Mathieu-Daudé wrote:
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/qemu/bswap.h | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
> index 41131d3d76e..fed96dddd7a 100644
> --- a/include/qemu/bswap.h
> +++ b/include/qemu/bswap.h
> @@ -38,29 +38,31 @@ static inline uint64_t bswap64(uint64_t x)
>
> static inline void bswap16s(uint16_t *s)
> {
> - *s = bswap16(*s);
> + *s = __builtin_bswap16(*s);
> }
>
> static inline void bswap32s(uint32_t *s)
> {
> - *s = bswap32(*s);
> + *s = __builtin_bswap32(*s);
> }
>
> static inline void bswap64s(uint64_t *s)
> {
> - *s = bswap64(*s);
> + *s = __builtin_bswap64(*s);
> }
>
> #if defined(HOST_WORDS_BIGENDIAN)
> #define be_bswap(v, size) (v)
> -#define le_bswap(v, size) glue(bswap, size)(v)
> +#define le_bswap(v, size) glue(__builtin_bswap, size)(v)
> #define be_bswaps(v, size)
> -#define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
> +#define le_bswaps(p, size) \
> + do { *p = glue(__builtin_bswap, size)(*p); } while (0)
> #else
> #define le_bswap(v, size) (v)
> -#define be_bswap(v, size) glue(bswap, size)(v)
> +#define be_bswap(v, size) glue(__builtin_bswap, size)(v)
> #define le_bswaps(v, size)
> -#define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0)
> +#define be_bswaps(p, size) \
> + do { *p = glue(__builtin_bswap, size)(*p); } while (0)
> #endif
What's the advantage of the renaming here if bswap is already #defined
to the builtin function (or another useful function from a system
header)? This just looks like code churn to me?
Thomas
- [PATCH v2 0/8] qemu/bswap: Use compiler __builtin_bswap(), Philippe Mathieu-Daudé, 2020/09/28
- [PATCH v2 1/8] qemu/bswap: Remove unused qemu_bswap_len(), Philippe Mathieu-Daudé, 2020/09/28
- [PATCH v2 2/8] qemu/bswap: Replace bswapXX() by compiler __builtin_bswap(), Philippe Mathieu-Daudé, 2020/09/28
- [PATCH v2 4/8] qemu/bswap: Remove <byteswap.h> dependency, Philippe Mathieu-Daudé, 2020/09/28
- [PATCH v2 3/8] qemu/bswap: Replace bswapXXs() by compiler __builtin_bswap(), Philippe Mathieu-Daudé, 2020/09/28
- Re: [PATCH v2 3/8] qemu/bswap: Replace bswapXXs() by compiler __builtin_bswap(),
Thomas Huth <=
- [PATCH v2 5/8] qemu/bswap: Use compiler __builtin_bswap() on Haiku, Philippe Mathieu-Daudé, 2020/09/28
- Re: [PATCH v2 5/8] qemu/bswap: Use compiler __builtin_bswap() on Haiku, Thomas Huth, 2020/09/28
- [PATCH v2 6/8] qemu/bswap: Use compiler __builtin_bswap() on FreeBSD, Philippe Mathieu-Daudé, 2020/09/28