]> git.ipfire.org Git - thirdparty/kernel/linux.git/blame - tools/include/tools/endian.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/kernel/linux.git] / tools / include / tools / endian.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
8c2b0dc8
PF
2#ifndef _TOOLS_ENDIAN_H
3#define _TOOLS_ENDIAN_H
4
5#include <byteswap.h>
6
7#if __BYTE_ORDER == __LITTLE_ENDIAN
8
9#ifndef htole16
10#define htole16(x) (x)
11#endif
12#ifndef htole32
13#define htole32(x) (x)
14#endif
15#ifndef htole64
16#define htole64(x) (x)
17#endif
18
ec84284b
PF
19#ifndef le16toh
20#define le16toh(x) (x)
21#endif
22
23#ifndef le32toh
24#define le32toh(x) (x)
25#endif
26
27#ifndef le64toh
28#define le64toh(x) (x)
29#endif
30
8c2b0dc8
PF
31#else /* __BYTE_ORDER */
32
33#ifndef htole16
34#define htole16(x) __bswap_16(x)
35#endif
36#ifndef htole32
37#define htole32(x) __bswap_32(x)
38#endif
39#ifndef htole64
40#define htole64(x) __bswap_64(x)
41#endif
42
ec84284b
PF
43#ifndef le16toh
44#define le16toh(x) __bswap_16(x)
45#endif
46
47#ifndef le32toh
48#define le32toh(x) __bswap_32(x)
49#endif
50
51#ifndef le64toh
52#define le64toh(x) __bswap_64(x)
53#endif
54
8c2b0dc8
PF
55#endif
56
57#endif /* _TOOLS_ENDIAN_H */