diff --git a/include/mem.h b/include/mem.h index a446fc82..56fed308 100644 --- a/include/mem.h +++ b/include/mem.h @@ -24,7 +24,6 @@ #include #include "types.h" - #include "byteorder.h" typedef Bit32u PhysPt; @@ -67,84 +66,6 @@ static INLINE void host_writeb(uint8_t *var, const uint8_t val) *var = val; } -// host_to_le functions allow for byte order conversion on big endian -// architectures while respecting memory alignment on low endian. -// -// It is extremely unlikely that we'll ever try to compile on big endian arch -// with a compiler missing __builtin_bswap*, so let's not overcomplicate -// things. -// -// __builtin_bswap* is supported since GCC 4.3 and Clang 3.4 - -constexpr static INLINE uint8_t host_to_le(uint8_t val) { - return val; -} - -#if defined(WORDS_BIGENDIAN) - -constexpr static INLINE int16_t host_to_le(int16_t val) { - return __builtin_bswap16(val); -} - -constexpr static INLINE uint16_t host_to_le(uint16_t val) { - return __builtin_bswap16(val); -} - -constexpr static INLINE uint32_t host_to_le(uint32_t val) { - return __builtin_bswap32(val); -} - -constexpr static INLINE uint64_t host_to_le(uint64_t val) -{ - return __builtin_bswap64(val); -} - -#else - -constexpr static INLINE int16_t host_to_le(int16_t val) { - return val; -} - -constexpr static INLINE uint16_t host_to_le(uint16_t val) { - return val; -} - -constexpr static INLINE uint32_t host_to_le(uint32_t val) { - return val; -} - -constexpr static INLINE uint64_t host_to_le(uint64_t val) -{ - return val; -} - -#endif - -constexpr static INLINE uint8_t le_to_host(uint8_t val) -{ - return host_to_le(val); -} - -constexpr static INLINE int16_t le_to_host(int16_t val) -{ - return host_to_le(val); -} - -constexpr static INLINE uint16_t le_to_host(uint16_t val) -{ - return host_to_le(val); -} - -constexpr static INLINE uint32_t le_to_host(uint32_t val) -{ - return host_to_le(val); -} - -constexpr static INLINE uint64_t le_to_host(uint64_t val) -{ - return host_to_le(val); -} - // Read, write, and add using 16-bit words static INLINE uint16_t host_readw(const uint8_t *arr) {