endian.h 941 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef LIBNETDATA_ENDIAN_H
  2. #define LIBNETDATA_ENDIAN_H
  3. /** compatibility header for endian.h
  4. * This is a simple compatibility shim to convert
  5. * BSD/Linux endian macros to the Mac OS X equivalents.
  6. * It is public domain.
  7. * */
  8. #ifndef __APPLE__
  9. #error "This header file (endian.h) is MacOS X specific.\n"
  10. #endif /* __APPLE__ */
  11. #include <libkern/OSByteOrder.h>
  12. #define htobe16(x) OSSwapHostToBigInt16(x)
  13. #define htole16(x) OSSwapHostToLittleInt16(x)
  14. #define be16toh(x) OSSwapBigToHostInt16(x)
  15. #define le16toh(x) OSSwapLittleToHostInt16(x)
  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. #define htobe64(x) OSSwapHostToBigInt64(x)
  21. #define htole64(x) OSSwapHostToLittleInt64(x)
  22. #define be64toh(x) OSSwapBigToHostInt64(x)
  23. #define le64toh(x) OSSwapLittleToHostInt64(x)
  24. #endif /* LIBNETDATA_ENDIAN_H */