Documentation: support glibc versions without htole macros
[firefly-linux-kernel-4.4.55.git] / tools / include / tools / endian.h
1 #ifndef _TOOLS_ENDIAN_H
2 #define _TOOLS_ENDIAN_H
3
4 #include <byteswap.h>
5
6 #if __BYTE_ORDER == __LITTLE_ENDIAN
7
8 #ifndef htole16
9 #define htole16(x) (x)
10 #endif
11 #ifndef htole32
12 #define htole32(x) (x)
13 #endif
14 #ifndef htole64
15 #define htole64(x) (x)
16 #endif
17
18 #else /* __BYTE_ORDER */
19
20 #ifndef htole16
21 #define htole16(x) __bswap_16(x)
22 #endif
23 #ifndef htole32
24 #define htole32(x) __bswap_32(x)
25 #endif
26 #ifndef htole64
27 #define htole64(x) __bswap_64(x)
28 #endif
29
30 #endif
31
32 #endif /* _TOOLS_ENDIAN_H */