xref: /linux/tools/include/nolibc/endian.h (revision ee60c510fb3468ec6fab98419218c4e7b37e2ca3)
1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
2 /*
3  * Byte order conversion for NOLIBC
4  * Copyright (C) 2026 Thomas Weißschuh <linux@weissschuh.net>
5  */
6 
7 /* make sure to include all global symbols */
8 #include "nolibc.h"
9 
10 #ifndef _NOLIBC_ENDIAN_H
11 #define _NOLIBC_ENDIAN_H
12 
13 #include "stdint.h"
14 
15 #include <asm/byteorder.h>
16 
17 #define htobe16(_x) __cpu_to_be16(_x)
18 #define htole16(_x) __cpu_to_le16(_x)
19 #define be16toh(_x) __be16_to_cpu(_x)
20 #define le16toh(_x) __le16_to_cpu(_x)
21 
22 #define htobe32(_x) __cpu_to_be32(_x)
23 #define htole32(_x) __cpu_to_le32(_x)
24 #define be32toh(_x) __be32_to_cpu(_x)
25 #define le32toh(_x) __le32_to_cpu(_x)
26 
27 #define htobe64(_x) __cpu_to_be64(_x)
28 #define htole64(_x) __cpu_to_le64(_x)
29 #define be64toh(_x) __be64_to_cpu(_x)
30 #define le64toh(_x) __le64_to_cpu(_x)
31 
32 #endif /* _NOLIBC_ENDIAN_H */
33