4ea34cdd0f95c354ebc15bae00c54fb249f18db1
[openwrt-10.03/.git] / tools / include / endian.h
1 #ifndef __endian_compat_h
2 #define __endian_compat_h
3
4 #if defined(__linux__)
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 #else
13 #include <machine/endian.h>
14 #define bswap_16(x) swap16(x)
15 #define bswap_32(x) swap32(x)
16 #define bswap_64(x) swap64(x)
17 #endif
18
19 #ifndef __BYTE_ORDER
20 #define __BYTE_ORDER BYTE_ORDER
21 #endif
22 #ifndef __BIG_ENDIAN
23 #define __BIG_ENDIAN BIG_ENDIAN
24 #endif
25 #ifndef __LITTLE_ENDIAN
26 #define __LITTLE_ENDIAN LITTLE_ENDIAN
27 #endif
28
29 #endif