20 #define __has_builtin(x) 0 // Compatibility with non-clang compilers 22 #if (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \ 23 || (defined(__GNUC__ ) && \ 24 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) 25 #define HAVE_BSWAP_INTRINSICS 34 ::memcpy(&org, &v_in_out,
sizeof(T));
35 const uint16_t val_rev = ((org & 0xff00) >> 8) | ((org & 0x00ff) << 8);
36 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
43 ::memcpy(&org, &v_in_out,
sizeof(T));
47 #elif defined(HAVE_BSWAP_INTRINSICS) 48 __builtin_bswap32(org);
50 ((org & 0xff000000) >> (3*8)) | ((org & 0x00ff0000) >> (1*8)) | ((org & 0x0000ff00) << (1*8)) | ((org & 0x000000ff) << (3*8));
52 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
59 ::memcpy(&org, &v_in_out,
sizeof(T));
61 uint64_t val_rev =_byteswap_uint64(org);
62 #elif defined(HAVE_BSWAP_INTRINSICS) 63 uint64_t val_rev =__builtin_bswap64(org);
67 for (i=7,j=7;i>=4;i--,j-=2)
68 val_rev |= ((org & ( UINT64_C(0xff) << (i*8))) >> (j*8));
69 for (i=3,j=1;i>=0;i--,j+=2)
70 val_rev |= ((org & ( UINT64_C(0xff) << (i*8))) << (j*8));
72 ::memcpy(&v_in_out, &val_rev,
sizeof(T));
118 #ifdef HAVE_LONG_DOUBLE 121 ::memcpy(&dat[0], &v_in_out,
sizeof(
long double));
122 std::swap(dat[0],dat[1]);
125 ::memcpy(&v_in_out, &dat[0],
sizeof(
long double));
void BASE_IMPEXP memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) MRPT_NO_THROWS
An OS and compiler independent version of "memcpy".
unsigned __int16 uint16_t
void reverseBytesInPlace_4b(T &v_in_out)
void BASE_IMPEXP 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