1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TOOLS_ENDIAN_H
3 #define _TOOLS_ENDIAN_H
7 #if __BYTE_ORDER == __LITTLE_ENDIAN
10 #define htole16(x) (x)
13 #define htole32(x) (x)
16 #define htole64(x) (x)
20 #define le16toh(x) (x)
24 #define le32toh(x) (x)
28 #define le64toh(x) (x)
31 #else /* __BYTE_ORDER */
34 #define htole16(x) __bswap_16(x)
37 #define htole32(x) __bswap_32(x)
40 #define htole64(x) __bswap_64(x)
44 #define le16toh(x) __bswap_16(x)
48 #define le32toh(x) __bswap_32(x)
52 #define le64toh(x) __bswap_64(x)
57 #endif /* _TOOLS_ENDIAN_H */