23 #if __has_include(<sys/param.h>)
29 #if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || (defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
30 #define IS_LITTLE_ENDIAN() 0
31 #elif defined(_WIN32) || (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
32 #define IS_LITTLE_ENDIAN() 1
34 #error Could not determine machine endianness in the preprocessor!
63 return "Little Endian";
65 return "Big Endian with BitSwap";
67 return "Little Endian with BitSwap";
127 return accumulatedEndiannessDiff;
132 return (uint16_t)(((uint16_t)(x) & 0xFFU) << 8 | ((uint16_t)(x) & 0xFF00U) >> 8);
136 return (uint32_t)(((uint32_t)(x) & 0xFF) << 24 | ((uint32_t)(x) & 0xFF00) << 8 | ((uint32_t)(x) & 0xFF0000) >> 8 | ((uint32_t)(x) & 0xFF000000) >> 24);
140 return (uint64_t)((((uint64_t)(x) & 0xFF) << 56) | ((uint64_t)(x) & 0xFF00ULL) << 40 |((uint64_t)(x) & 0xFF0000ULL) << 24 |((uint64_t)(x) & 0xFF000000ULL) << 8 |((uint64_t)(x) & 0xFF00000000ULL) >> 8 |((uint64_t)(x) & 0xFF0000000000ULL) >> 24 | ((uint64_t)(x) & 0xFF000000000000ULL) >> 40 | ((uint64_t)(x) & 0xFF00000000000000ULL) >> 56);
146 return ((uint8_t)(x));
163 return ((uint8_t)(x));
180 return ((uint8_t)(x));
196 return ((uint8_t)(x));
214 return (((x & 0x80)>>7) | ((x & 0x40)>>5) | ((x & 0x20)>>3) | ((x & 0x10)>>1) | ((x & 0x08) << 1) | ((x & 0x04) << 3) | ((x & 0x02) << 5) | ((x & 0x01) << 7));
218 return (((x & 0x8080)>>7) | ((x & 0x4040)>>5) | ((x & 0x2020)>>3) | ((x & 0x1010)>>1) | ((x & 0x0808) << 1) | ((x & 0x0404) << 3) | ((x & 0x0202) << 5) | ((x & 0x0101) << 7));
222 return (((x & 0x80808080)>>7) | ((x & 0x40404040)>>5) | ((x & 0x20202020)>>3) | ((x & 0x10101010)>>1) | ((x & 0x08080808) << 1) | ((x & 0x04040404) << 3) | ((x & 0x02020202) << 5) | ((x & 0x01010101) << 7));
226 return (((x & 0x8080808080808080)>>7) | ((x & 0x4040404040404040)>>5) | ((x & 0x2020202020202020)>>3) | ((x & 0x1010101010101010)>>1) | ((x & 0x0808080808080808) << 1) | ((x & 0x0404040404040404) << 3) | ((x & 0x0202020202020202) << 5) | ((x & 0x0101010101010101) << 7));
231 return ((uint8_t)(x));
244 return ((uint16_t)(x));
257 return ((uint32_t)(x));
270 return ((uint64_t)(x));
Endianness
< Endianness in byteman is represented not only by big/little endian, but also by potential bit swapp...
@ BE_BS
Big endian with bit swaps inside each byte.
@ LE_BS
Little endian with bit swaps inside each byte.
@ LE
Little endian ("LE" instead of full-er name, so it does not conflict with linux's reserved endianess ...
@ BE
Big endian ("BE" instead of full-er name, so it does not conflict with linux's reserved endianess wor...
@ NATIVE
System native will always be the fastest endianess to process.
bool isBitSwap(Endianness e)
uint64_t NativeToBigEndian64(uint64_t x)
uint8_t BigEndianToNative8(uint8_t x)
uint16_t BitSwap16(uint16_t x)
uint8_t BitSwap8(uint8_t x)
uint16_t swapbytes16(uint16_t x)
uint8_t LittleEndianToNative8(uint8_t x)
uint16_t NativeToLittleEndian16(uint16_t x)
Endianness toggleEndianBitSwap(Endianness e, bool toggle=true)
uint32_t NativeToLittleEndian32(uint32_t x)
uint64_t BitSwap64(uint64_t x)
uint32_t BigEndianToNative32(uint32_t x)
uint64_t BigEndianToNative64(uint64_t x)
uint32_t NativeToAnyEndianness32(uint32_t x, Endianness e)
uint64_t NativeToLittleEndian64(uint64_t x)
uint32_t swapbytes32(uint32_t x)
uint32_t NativeToBigEndian32(uint32_t x)
Endianness toggleEndianness(Endianness e, bool toggle=true)
uint64_t NativeToAnyEndianness64(uint64_t x, Endianness e)
std::string to_string(Endianness e)
uint16_t NativeToBigEndian16(uint16_t x)
uint8_t NativeToAnyEndianness8(uint8_t x, Endianness e)
uint64_t LittleEndianToNative64(uint64_t x)
uint32_t LittleEndianToNative32(uint32_t x)
uint16_t NativeToAnyEndianness16(uint16_t x, Endianness e)
uint32_t BitSwap32(uint32_t x)
uint64_t swapbytes64(uint64_t x)
Endianness diff(Endianness e1, Endianness e2)
uint16_t LittleEndianToNative16(uint16_t x)
uint8_t NativeToLittleEndian8(uint8_t x)
uint8_t NativeToBigEndian8(uint8_t x)
uint16_t BigEndianToNative16(uint16_t x)