On 8/16/21 9:13 PM, [email protected] wrote:
> From: Matheus Ferst <[email protected]>
>
> 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 <[email protected]>
> ---
> 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 */
>