20 #define __has_builtin(x) 0 // Compatibility with non-clang compilers 23 defined(__clang__) && __has_builtin(__builtin_bswap32) && \ 24 __has_builtin(__builtin_bswap64)) || \ 25 (defined(__GNUC__) && \ 26 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) 27 #define HAVE_BSWAP_INTRINSICS 38 const uint16_t val_rev = ((org & 0xff00) >> 8) | ((org & 0x00ff) << 8);
39 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
56 #elif defined(HAVE_BSWAP_INTRINSICS) 57 __builtin_bswap32(org);
59 ((org & 0xff000000) >> (3 * 8)) | ((org & 0x00ff0000) >> (1 * 8)) |
60 ((org & 0x0000ff00) << (1 * 8)) | ((org & 0x000000ff) << (3 * 8));
62 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
77 uint64_t val_rev = _byteswap_uint64(org);
78 #elif defined(HAVE_BSWAP_INTRINSICS) 79 uint64_t val_rev = __builtin_bswap64(org);
83 for (i = 7, j = 7; i >= 4; i--, j -= 2)
84 val_rev |= ((org & (UINT64_C(0xff) << (i * 8))) >> (j * 8));
85 for (i = 3, j = 1; i >= 0; i--, j += 2)
86 val_rev |= ((org & (UINT64_C(0xff) << (i * 8))) << (j * 8));
88 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
148 #ifdef HAVE_LONG_DOUBLE 153 &dat[0], &v_in_out,
sizeof(
long double));
157 std::swap(dat[0], dat[1]);
160 ::memcpy(&v_in_out, &dat[0],
sizeof(
long double));
unsigned __int16 uint16_t
void reverseBytesInPlace_4b(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) ...
unsigned __int64 uint64_t
void reverseBytesInPlace_2b(T &v_in_out)
void reverseBytesInPlace_8b(T &v_in_out)
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".