4 #include "shore-config.h" 12 #ifdef WORDS_BIGENDIAN 13 inline bool is_big_endian() {
return true; }
14 inline bool is_little_endian() {
return false; }
16 #else // WORDS_BIGENDIAN 17 #ifdef WORDS_LITTLEENDIAN 19 inline bool is_big_endian() {
23 inline bool is_little_endian() {
27 #else // WORDS_LITTLEENDIAN 29 #error "Huh?! Neither BigEndian nor LittleEndian? config.h seems not included in the path." 30 #endif // WORDS_LITTLEENDIAN 31 #endif // WORDS_BIGENDIAN 42 #ifdef WORDS_BIGENDIAN 43 *
reinterpret_cast<uint16_t*
>(dest) = value;
44 #else // WORDS_BIGENDIAN 45 unsigned char* b =
reinterpret_cast<unsigned char*
> (dest);
48 #endif // WORDS_BIGENDIAN 53 #ifdef WORDS_BIGENDIAN 54 *
reinterpret_cast<uint32_t*
>(dest) = value;
55 #else // WORDS_BIGENDIAN 56 unsigned char* b =
reinterpret_cast<unsigned char*
> (dest);
58 b[1] = (value & 0xFF0000) >> 16;
59 b[2] = (value & 0xFF00) >> 8;
61 #endif // WORDS_BIGENDIAN 66 #ifdef WORDS_BIGENDIAN 67 *
reinterpret_cast<uint64_t*
>(dest) = value;
68 #else // WORDS_BIGENDIAN 69 unsigned char* b =
reinterpret_cast<unsigned char*
> (dest);
71 b[1] = (value & 0xFF000000000000) >> 48;
72 b[2] = (value & 0xFF0000000000) >> 40;
73 b[3] = (value & 0xFF00000000) >> 32;
74 b[4] = (value & 0xFF000000) >> 24;
75 b[5] = (value & 0xFF0000) >> 16;
76 b[6] = (value & 0xFF00) >> 8;
78 #endif // WORDS_BIGENDIAN 83 #ifdef WORDS_BIGENDIAN 84 return *
reinterpret_cast<const uint16_t*
>(buf);
85 #else // WORDS_BIGENDIAN 86 const unsigned char* b =
reinterpret_cast<const unsigned char*
> (buf);
87 return (b[0] << 8) | b[1];
88 #endif // WORDS_BIGENDIAN 93 #ifdef WORDS_BIGENDIAN 94 return *
reinterpret_cast<const uint32_t*
>(buf);
95 #else // WORDS_BIGENDIAN 96 const unsigned char* b =
reinterpret_cast<const unsigned char*
> (buf);
97 return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
98 #endif // WORDS_BIGENDIAN 103 #ifdef WORDS_BIGENDIAN 104 return *
reinterpret_cast<const uint64_t*
>(buf);
105 #else // WORDS_BIGENDIAN 106 const unsigned char* b =
reinterpret_cast<const unsigned char*
> (buf);
107 return ((uint64_t)b[0] << 56) | ((uint64_t)b[1] << 48)
108 | ((uint64_t)b[2] << 40) | ((uint64_t)b[3] << 32)
109 | ((uint64_t)b[4] << 24) | ((uint64_t)b[5] << 16)
110 | ((uint64_t)b[6] << 8) | (uint64_t)b[7];
111 #endif // WORDS_BIGENDIAN 141 #endif // __W_ENDIAN_H void deserialize_ho(uint16_t &value)
Definition: w_endian.h:129
void serialize_be(void *dest, uint16_t value)
Definition: w_endian.h:117
uint16_t deserialize16_ho(const void *buf)
Definition: w_endian.h:82
void serialize16_be(void *dest, uint16_t value)
Definition: w_endian.h:41
void serialize32_be(void *dest, uint32_t value)
Definition: w_endian.h:52
void serialize64_be(void *dest, uint64_t value)
Definition: w_endian.h:65
uint64_t deserialize64_ho(const void *buf)
Definition: w_endian.h:102
uint32_t deserialize32_ho(const void *buf)
Definition: w_endian.h:92