endian.h 810 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef __endian_compat_h
  2. #define __endian_compat_h
  3. #if defined(__linux__) || defined(__CYGWIN__)
  4. #include <byteswap.h>
  5. #include_next <endian.h>
  6. #elif defined(__APPLE__)
  7. #include <machine/endian.h>
  8. #include <machine/byte_order.h>
  9. #define bswap_16(x) NXSwapShort(x)
  10. #define bswap_32(x) NXSwapInt(x)
  11. #define bswap_64(x) NXSwapLongLong(x)
  12. #elif defined(__FreeBSD__)
  13. #include <sys/endian.h>
  14. #define bswap_16(x) bswap16(x)
  15. #define bswap_32(x) bswap32(x)
  16. #define bswap_64(x) bswap64(x)
  17. #else
  18. #include <machine/endian.h>
  19. #define bswap_16(x) swap16(x)
  20. #define bswap_32(x) swap32(x)
  21. #define bswap_64(x) swap64(x)
  22. #endif
  23. #ifndef __BYTE_ORDER
  24. #define __BYTE_ORDER BYTE_ORDER
  25. #endif
  26. #ifndef __BIG_ENDIAN
  27. #define __BIG_ENDIAN BIG_ENDIAN
  28. #endif
  29. #ifndef __LITTLE_ENDIAN
  30. #define __LITTLE_ENDIAN LITTLE_ENDIAN
  31. #endif
  32. #endif