[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-6.2 1/2] include/qemu/int128.h: introduce bswap128s
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH for-6.2 1/2] include/qemu/int128.h: introduce bswap128s |
Date: |
Tue, 17 Aug 2021 11:27:16 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 8/16/21 9:13 PM, matheus.ferst@eldorado.org.br wrote:
> From: Matheus Ferst <matheus.ferst@eldorado.org.br>
>
> Introduces bswap128s based on bswap128. Since bswap128 is defined using
> int128_* methods available in either CONFIG_INT128 or !CONFIG_INT128
> builds, place both outside of #ifdef CONFIG_INT128.
>
> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
> ---
> include/qemu/int128.h | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/include/qemu/int128.h b/include/qemu/int128.h
> index 64500385e3..e0d385628c 100644
> --- a/include/qemu/int128.h
> +++ b/include/qemu/int128.h
> @@ -153,11 +153,6 @@ static inline void int128_subfrom(Int128 *a, Int128 b)
> *a -= b;
> }
>
> -static inline Int128 bswap128(Int128 a)
> -{
> - return int128_make128(bswap64(int128_gethi(a)),
> bswap64(int128_getlo(a)));
> -}
Personally I'd move this one to the other #ifdef side,
and implement here with __builtin_bswap128().
> #else /* !CONFIG_INT128 */
>
> typedef struct Int128 Int128;
> @@ -338,4 +333,15 @@ static inline void int128_subfrom(Int128 *a, Int128 b)
> }
> +static inline Int128 bswap128(Int128 a)
> +{
> + return int128_make128(bswap64(int128_gethi(a)),
> bswap64(int128_getlo(a)));
> +}
#endif /* CONFIG_INT128 */
And add this generic one here indeed:
> +static inline void bswap128s(Int128 *s)
> +{
> + *s = bswap128(*s);
> +}
> +
> #endif /* INT128_H */
>
[PATCH for-6.2 2/2] target/ppc: Don't swap 64-bit elements of AVR in gdbstub for user mode, matheus . ferst, 2021/08/16