Kagome
Polkadot Runtime Engine in C++17
endianness_utils.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_ENDIANNESS_UTILS_HPP
7 #define KAGOME_ENDIANNESS_UTILS_HPP
8 
9 #ifdef _MSC_VER
10 #define LE_BE_SWAP32 _byteswap_ulong
11 #define LE_BE_SWAP64 _byteswap_uint64
12 #else //_MSC_VER
13 #define LE_BE_SWAP32 __builtin_bswap32
14 #define LE_BE_SWAP64 __builtin_bswap64
15 #endif //_MSC_VER
16 
17 #ifdef __APPLE__
18 
19 #include <libkern/OSByteOrder.h>
20 
21 #define htobe16(x) OSSwapHostToBigInt16(x)
22 #define htole16(x) OSSwapHostToLittleInt16(x)
23 #define be16toh(x) OSSwapBigToHostInt16(x)
24 #define le16toh(x) OSSwapLittleToHostInt16(x)
25 
26 #define htobe32(x) OSSwapHostToBigInt32(x)
27 #define htole32(x) OSSwapHostToLittleInt32(x)
28 #define be32toh(x) OSSwapBigToHostInt32(x)
29 #define le32toh(x) OSSwapLittleToHostInt32(x)
30 
31 #define htobe64(x) OSSwapHostToBigInt64(x)
32 #define htole64(x) OSSwapHostToLittleInt64(x)
33 #define be64toh(x) OSSwapBigToHostInt64(x)
34 #define le64toh(x) OSSwapLittleToHostInt64(x)
35 
36 #endif // __APPLE__
37 
38 #endif // KAGOME_ENDIANNESS_UTILS_HPP