From: Philippe Mathieu-Daudé Date: Fri, 9 Jan 2026 14:49:41 +0000 (+0100) Subject: bswap: Consistently use builtin bswap() functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f44866719f6e1d25d5dc853e4737c1cb945ef4e7;p=thirdparty%2Fqemu.git bswap: Consistently use builtin bswap() functions Since these headers use some __builtin_bswap*(), use it consistently in all the cases, allowing to remove the "qemu/bswap.h" inclusion (which only defines bswap* to the builtin equivalent). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-ID: <20260109164742.58041-5-philmd@linaro.org> --- diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index dd558589cb..0777a2bb60 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -380,7 +380,7 @@ static inline uint16_t revbit16(uint16_t x) return __builtin_bitreverse16(x); #else /* Assign the correct byte position. */ - x = bswap16(x); + x = __builtin_bswap16(x); /* Assign the correct nibble position. */ x = ((x & 0xf0f0) >> 4) | ((x & 0x0f0f) << 4); @@ -403,7 +403,7 @@ static inline uint32_t revbit32(uint32_t x) return __builtin_bitreverse32(x); #else /* Assign the correct byte position. */ - x = bswap32(x); + x = __builtin_bswap32(x); /* Assign the correct nibble position. */ x = ((x & 0xf0f0f0f0u) >> 4) | ((x & 0x0f0f0f0fu) << 4); @@ -426,7 +426,7 @@ static inline uint64_t revbit64(uint64_t x) return __builtin_bitreverse64(x); #else /* Assign the correct byte position. */ - x = bswap64(x); + x = __builtin_bswap64(x); /* Assign the correct nibble position. */ x = ((x & 0xf0f0f0f0f0f0f0f0ull) >> 4) | ((x & 0x0f0f0f0f0f0f0f0full) << 4); diff --git a/include/qemu/int128.h b/include/qemu/int128.h index 174bd7dafb..2b8dd4dec9 100644 --- a/include/qemu/int128.h +++ b/include/qemu/int128.h @@ -189,7 +189,8 @@ static inline Int128 bswap128(Int128 a) #if __has_builtin(__builtin_bswap128) return __builtin_bswap128(a); #else - return int128_make128(bswap64(int128_gethi(a)), bswap64(int128_getlo(a))); + return int128_make128(__builtin_bswap64(int128_gethi(a)), + __builtin_bswap64(int128_getlo(a))); #endif } @@ -451,7 +452,7 @@ static inline void int128_subfrom(Int128 *a, Int128 b) static inline Int128 bswap128(Int128 a) { - return int128_make128(bswap64(a.hi), bswap64(a.lo)); + return int128_make128(__builtin_bswap64(a.hi), __builtin_bswap64(a.lo)); } static inline int clz128(Int128 a)