19 #define __has_builtin(x) 0 // Compatibility with non-clang compilers 22 defined(__clang__) && __has_builtin(__builtin_bswap32) && \ 23 __has_builtin(__builtin_bswap64)) || \ 24 (defined(__GNUC__) && \ 25 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) 26 #define HAVE_BSWAP_INTRINSICS 37 const uint16_t val_rev = ((org & 0xff00) >> 8) | ((org & 0x00ff) << 8);
38 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
55 #elif defined(HAVE_BSWAP_INTRINSICS) 56 __builtin_bswap32(org);
58 ((org & 0xff000000) >> (3 * 8)) | ((org & 0x00ff0000) >> (1 * 8)) |
59 ((org & 0x0000ff00) << (1 * 8)) | ((org & 0x000000ff) << (3 * 8));
61 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
76 uint64_t val_rev = _byteswap_uint64(org);
77 #elif defined(HAVE_BSWAP_INTRINSICS) 78 uint64_t val_rev = __builtin_bswap64(org);
82 for (i = 7, j = 7; i >= 4; i--, j -= 2)
83 val_rev |= ((org & (UINT64_C(0xff) << (i * 8))) >> (j * 8));
84 for (i = 3, j = 1; i >= 0; i--, j += 2)
85 val_rev |= ((org & (UINT64_C(0xff) << (i * 8))) << (j * 8));
87 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
147 #ifdef HAVE_LONG_DOUBLE 152 &dat[0], &v_in_out,
sizeof(
long double));
156 std::swap(dat[0], dat[1]);
159 ::memcpy(&v_in_out, &dat[0],
sizeof(
long double));
unsigned __int16 uint16_t
void reverseBytesInPlace_4b(T &v_in_out)
void reverseBytesInPlace_8b(T &v_in_out)
void reverseBytesInPlace(bool &v_in_out)
Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) ...
void reverseBytesInPlace_2b(T &v_in_out)
unsigned __int64 uint64_t
unsigned __int32 uint32_t
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".