1
0
Fork 0

Eliminate old host_to_le functions

This commit is contained in:
krcroft 2020-04-14 17:36:01 -07:00 committed by Patryk Obara
parent 5bf7e63030
commit 090e039e29

View file

@ -24,7 +24,6 @@
#include <cstring>
#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)
{