| 1 | #ifndef LIBNETDATA_BYTE_ORDER_H |
| 2 | #define LIBNETDATA_BYTE_ORDER_H |
| 3 | |
| 4 | /** compatibility header for endian.h |
| 5 | * This is a simple compatibility shim to convert |
| 6 | * BSD/Linux endian macros to the Mac OS X equivalents. |
| 7 | * It is public domain. |
| 8 | * */ |
| 9 | |
| 10 | #ifndef __APPLE__ |
| 11 | #error "This header file (endian.h) is MacOS X specific.\n" |
| 12 | #endif /* __APPLE__ */ |
| 13 | |
| 14 | |
| 15 | #include <libkern/OSByteOrder.h> |
| 16 | |
| 17 | #define htobe16(x) OSSwapHostToBigInt16(x) |
| 18 | #define htole16(x) OSSwapHostToLittleInt16(x) |
| 19 | #define be16toh(x) OSSwapBigToHostInt16(x) |
| 20 | #define le16toh(x) OSSwapLittleToHostInt16(x) |
| 21 | |
| 22 | #define htobe32(x) OSSwapHostToBigInt32(x) |
| 23 | #define htole32(x) OSSwapHostToLittleInt32(x) |
| 24 | #define be32toh(x) OSSwapBigToHostInt32(x) |
| 25 | #define le32toh(x) OSSwapLittleToHostInt32(x) |
| 26 | |
| 27 | #define htobe64(x) OSSwapHostToBigInt64(x) |
| 28 | #define htole64(x) OSSwapHostToLittleInt64(x) |
| 29 | #define be64toh(x) OSSwapBigToHostInt64(x) |
| 30 | #define le64toh(x) OSSwapLittleToHostInt64(x) |
| 31 | |
| 32 | #endif /* LIBNETDATA_BYTE_ORDER_H */ |