1#ifndef __endian_compat_h
2#define __endian_compat_h
3
4#if defined(__linux__) || defined(__CYGWIN__)
5#include <byteswap.h>
6#include_next <endian.h>
7#elif defined(__APPLE__)
8#include <machine/endian.h>
9#include <machine/byte_order.h>
10#define bswap_16(x) NXSwapShort(x)
11#define bswap_32(x) NXSwapInt(x)
12#define bswap_64(x) NXSwapLongLong(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#else
19#include <machine/endian.h>
20#define bswap_16(x) swap16(x)
21#define bswap_32(x) swap32(x)
22#define bswap_64(x) swap64(x)
23#endif
24
25#ifndef __BYTE_ORDER
26#define __BYTE_ORDER BYTE_ORDER
27#endif
28#ifndef __BIG_ENDIAN
29#define __BIG_ENDIAN BIG_ENDIAN
30#endif
31#ifndef __LITTLE_ENDIAN
32#define __LITTLE_ENDIAN LITTLE_ENDIAN
33#endif
34
35#endif
36