12 #ifndef SIMPLE_ENDIAN_HPP 13 #define SIMPLE_ENDIAN_HPP 17 #ifndef __BYTE_ORDER__ 18 #error "__BYTE_ORDER__ is not defined by your system - are you compiling under GCC?" 22 namespace SimpleEndian {
23 uint32_t htole32(uint32_t host_32bits) {
24 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 26 #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 27 return __builtin_bswap32(host_32bits);
28 #elif (__BYTE_ORDER__ == __ORDER_PDP_ENDIAN__) 29 return (((host_32bits & 0xffff0000) >> 0x10) | ((host_32bits & 0x0000ffff) << 0x10));
31 #error "__BYTE_ORDER__ currently defined is not supported - please submit a bug report"