13 #ifndef TLX_MATH_BSWAP_HEADER 14 #define TLX_MATH_BSWAP_HEADER 32 return ((x >> 8) & 0x00FFUL) | ((x << 8) & 0xFF00UL);
35 #if defined(__GNUC__) || defined(__clang__) 38 static inline uint16_t
bswap16(
const uint16_t& v) {
39 return __builtin_bswap16(v);
42 #elif defined(_MSC_VER) 45 static inline uint16_t
bswap16(
const uint16_t& v) {
46 return _byteswap_ushort(v);
52 static inline uint16_t
bswap16(
const uint16_t& v) {
63 return ((x >> 24) & 0x000000FFUL) | ((x << 24) & 0xFF000000UL) |
64 ((x >> 8) & 0x0000FF00UL) | ((x << 8) & 0x00FF0000UL);
67 #if defined(__GNUC__) || defined(__clang__) 70 static inline uint32_t
bswap32(
const uint32_t& v) {
71 return __builtin_bswap32(v);
74 #elif defined(_MSC_VER) 77 static inline uint32_t
bswap32(
const uint32_t& v) {
78 return _byteswap_ulong(v);
84 static inline uint32_t
bswap32(
const uint32_t& v) {
95 return ((x >> 56) & 0x00000000000000FFull) |
96 ((x >> 40) & 0x000000000000FF00ull) |
97 ((x >> 24) & 0x0000000000FF0000ull) |
98 ((x >> 8) & 0x00000000FF000000ull) |
99 ((x << 8) & 0x000000FF00000000ull) |
100 ((x << 24) & 0x0000FF0000000000ull) |
101 ((x << 40) & 0x00FF000000000000ull) |
102 ((x << 56) & 0xFF00000000000000ull);
105 #if defined(__GNUC__) || defined(__clang__) 108 static inline uint64_t
bswap64(
const uint64_t& v) {
109 return __builtin_bswap64(v);
112 #elif defined(_MSC_VER) 115 static inline uint64_t
bswap64(
const uint64_t& v) {
116 return _byteswap_uint64(v);
122 static inline uint64_t
bswap64(
const uint64_t& v) {
134 #endif // !TLX_MATH_BSWAP_HEADER static uint32_t bswap32(const uint32_t &v)
bswap32 - generic
static uint64_t bswap64(const uint64_t &v)
bswap64 - generic
static uint16_t bswap16(const uint16_t &v)
bswap16 - generic
static uint32_t bswap32_generic(const uint32_t &x)
bswap32 - generic implementation
static uint16_t bswap16_generic(const uint16_t &x)
bswap16 - generic implementation
static uint64_t bswap64_generic(const uint64_t &x)
bswap64 - generic implementation