endian_compat.h 884 B

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