| 1 | // SPDX-License-Identifier: GPL-3.0-only |
| 2 | |
| 3 | #ifndef MQTT_WSS_ENDIAN_COMPAT_H |
| 4 | #define MQTT_WSS_ENDIAN_COMPAT_H |
| 5 | |
| 6 | #ifdef __APPLE__ |
| 7 | #include <libkern/OSByteOrder.h> |
| 8 | |
| 9 | #define htobe16(x) OSSwapHostToBigInt16(x) |
| 10 | #define htole16(x) OSSwapHostToLittleInt16(x) |
| 11 | #define be16toh(x) OSSwapBigToHostInt16(x) |
| 12 | #define le16toh(x) OSSwapLittleToHostInt16(x) |
| 13 | |
| 14 | #define htobe32(x) OSSwapHostToBigInt32(x) |
| 15 | #define htole32(x) OSSwapHostToLittleInt32(x) |
| 16 | #define be32toh(x) OSSwapBigToHostInt32(x) |
| 17 | #define le32toh(x) OSSwapLittleToHostInt32(x) |
| 18 | |
| 19 | #define htobe64(x) OSSwapHostToBigInt64(x) |
| 20 | #define htole64(x) OSSwapHostToLittleInt64(x) |
| 21 | #define be64toh(x) OSSwapBigToHostInt64(x) |
| 22 | #define le64toh(x) OSSwapLittleToHostInt64(x) |
| 23 | #else |
| 24 | #ifdef __FreeBSD__ |
| 25 | #include <sys/endian.h> |
| 26 | #else |
| 27 | #include <endian.h> |
| 28 | #endif |
| 29 | #endif |
| 30 | |
| 31 | #endif /* MQTT_WSS_ENDIAN_COMPAT_H */ |