1 #ifndef ENDIAN_COMPAT_H 2 #define ENDIAN_COMPAT_H 3 4 #if defined(HAVE_ENDIAN_H) 5 #include <endian.h> 6 #elif defined(HAVE_SYS_ENDIAN_H) 7 #include <sys/endian.h> 8 #elif defined(HAVE_LIBKERN_OSBYTEORDER_H) 9 #include <libkern/OSByteOrder.h> 10 11 #define htobe16(x) OSSwapHostToBigInt16(x) 12 #define htole16(x) OSSwapHostToLittleInt16(x) 13 #define be16toh(x) OSSwapBigToHostInt16(x) 14 #define le16toh(x) OSSwapLittleToHostInt16(x) 15 16 #define htobe32(x) OSSwapHostToBigInt32(x) 17 #define htole32(x) OSSwapHostToLittleInt32(x) 18 #define be32toh(x) OSSwapBigToHostInt32(x) 19 #define le32toh(x) OSSwapLittleToHostInt32(x) 20 21 #define htobe64(x) OSSwapHostToBigInt64(x) 22 #define htole64(x) OSSwapHostToLittleInt64(x) 23 #define be64toh(x) OSSwapBigToHostInt64(x) 24 #define le64toh(x) OSSwapLittleToHostInt64(x) 25 #else 26 #error No endian.h available and no fallback code 27 #endif 28 29 #endif