1 #ifndef __endian_compat_h
2 #define __endian_compat_h
4 #if defined(__linux__) || defined(__CYGWIN__)
6 #include_next <endian.h>
7 #elif defined(__APPLE__)
8 #include <netinet/in.h>
9 #include <libkern/OSByteOrder.h>
10 #define bswap_16(x) OSSwapInt16(x)
11 #define bswap_32(x) OSSwapInt32(x)
12 #define bswap_64(x) OSSwapInt64(x)
13 #elif defined(__FreeBSD__)
14 #include <sys/endian.h>
15 #define bswap_16(x) bswap16(x)
16 #define bswap_32(x) bswap32(x)
17 #define bswap_64(x) bswap64(x)
18 #elif defined(__OpenBSD__)
19 #include <sys/types.h>
20 #define bswap_16(x) __swap16(x)
21 #define bswap_32(x) __swap32(x)
22 #define bswap_64(x) __swap64(x)
24 #include <machine/endian.h>
25 #define bswap_16(x) swap16(x)
26 #define bswap_32(x) swap32(x)
27 #define bswap_64(x) swap64(x)
31 #define __BYTE_ORDER BYTE_ORDER
34 #define __BIG_ENDIAN BIG_ENDIAN
36 #ifndef __LITTLE_ENDIAN
37 #define __LITTLE_ENDIAN LITTLE_ENDIAN