29 #define USE_BUILTIN_BYTESWAP 31 #undef USE_BUILTIN_BYTESWAP 45 const short testBig = 0x0100;
48 return *(
reinterpret_cast<const char*
>(&testBig));
54 const short testLittle = 0x0001;
57 return *(
reinterpret_cast<const char*
>(&testLittle));
63 #ifdef USE_BUILTIN_BYTESWAP 64 return __builtin_bswap32(u);
68 (((u) & 0xff000000) >> 24)
69 | (((u) & 0x00ff0000) >> 8)
70 | (((u) & 0x0000ff00) << 8)
71 | (((u) & 0x000000ff) << 24)
85 #ifdef USE_BUILTIN_BYTESWAP 86 return __builtin_bswap64(u);
90 (((u) & 0xff00000000000000ull) >> 56)
91 | (((u) & 0x00ff000000000000ull) >> 40)
92 | (((u) & 0x0000ff0000000000ull) >> 24)
93 | (((u) & 0x000000ff00000000ull) >> 8)
94 | (((u) & 0x00000000ff000000ull) << 8)
95 | (((u) & 0x0000000000ff0000ull) << 24)
96 | (((u) & 0x000000000000ff00ull) << 40)
97 | (((u) & 0x00000000000000ffull) << 56)
static uint32_t swap32(uint32_t)
Byte endian swapping for 32-bits.
static bool isLittle() noexcept
Runtime check for little endian.
static bool isBig() noexcept
Runtime check for big endian.
static uint64_t swap64(uint64_t)
Byte endian swapping for 64-bits.