Fix minor warnings and get rid of 'portable_endian_bswap.h' (in house

impl instead)
This commit is contained in:
SimoneN64
2024-09-25 21:21:49 +02:00
parent bcdf50e180
commit 56b9d69861
4 changed files with 58 additions and 153 deletions

22
src/utils/byteswap.hpp Normal file
View File

@@ -0,0 +1,22 @@
#pragma once
#include <common.hpp>
template <typename T>
T bswap(T);
template <>
inline u16 bswap(const u16 x) {
return (x & 0xFF00u) >> 8 | (x & 0x00FFu) << 8;
}
template <>
inline u32 bswap(const u32 x) {
return (x & 0xFF000000u) >> 24u | (x & 0x00FF0000u) >> 8u | (x & 0x0000FF00u) << 8u | (x & 0x000000FFu) << 24u;
}
template <>
inline u64 bswap(const u64 x) {
return (x & 0xFF00000000000000u) >> 56u | (x & 0x00FF000000000000u) >> 40u | (x & 0x0000FF0000000000u) >> 24u |
(x & 0x000000FF00000000u) >> 8u | (x & 0x00000000FF000000u) << 8u | (x & 0x0000000000FF0000u) << 24u |
(x & 0x000000000000FF00u) << 40u | (x & 0x00000000000000FFu) << 56u;
}