diff options
author | Nico Weber <thakis@chromium.org> | 2022-12-28 12:57:37 -0500 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-12-28 20:13:12 +0000 |
commit | 57126a0d3cd27237e0ada29b7f2e56751bfbc715 (patch) | |
tree | 77bf9833253041ed81cbb743ab8f054757992529 /AK | |
parent | a21703f1df33c06b3db05a9da554c7a4b116c0dc (diff) | |
download | serenity-57126a0d3cd27237e0ada29b7f2e56751bfbc715.zip |
AK: Make BigEndian<> and LittleEndian<> work with enum classes
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Endian.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/AK/Endian.h b/AK/Endian.h index 5ce022eff7..060f78dc9b 100644 --- a/AK/Endian.h +++ b/AK/Endian.h @@ -43,11 +43,11 @@ ALWAYS_INLINE constexpr T convert_between_host_and_little_endian(T value) return value; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ if constexpr (sizeof(T) == 8) - return __builtin_bswap64(value); + return static_cast<T>(__builtin_bswap64(static_cast<u64>(value))); if constexpr (sizeof(T) == 4) - return __builtin_bswap32(value); + return static_cast<T>(__builtin_bswap32(static_cast<u32>(value))); if constexpr (sizeof(T) == 2) - return __builtin_bswap16(value); + return static_cast<T>(__builtin_bswap16(static_cast<u16>(value))); if constexpr (sizeof(T) == 1) return value; #endif @@ -58,11 +58,11 @@ ALWAYS_INLINE constexpr T convert_between_host_and_big_endian(T value) { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ if constexpr (sizeof(T) == 8) - return __builtin_bswap64(value); + return static_cast<T>(__builtin_bswap64(static_cast<u64>(value))); if constexpr (sizeof(T) == 4) - return __builtin_bswap32(value); + return static_cast<T>(__builtin_bswap32(static_cast<u32>(value))); if constexpr (sizeof(T) == 2) - return __builtin_bswap16(value); + return static_cast<T>(__builtin_bswap16(static_cast<u16>(value))); if constexpr (sizeof(T) == 1) return value; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |