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);
52 const uint32_t val_rev =
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));
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));
149 int64_t
val = v_in_out.time_since_epoch().count();
154 #ifdef HAVE_LONG_DOUBLE 159 &dat[0], &v_in_out,
sizeof(
long double));
163 std::swap(dat[0], dat[1]);
166 std::memcpy(&v_in_out, &dat[0],
sizeof(
long double));
std::chrono::duration< rep, period > duration
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)
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".