xref: /dpdk/lib/eal/loongarch/include/rte_byteorder.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2022 Loongson Technology Corporation Limited
3  */
4 
5 #ifndef RTE_BYTEORDER_LOONGARCH_H
6 #define RTE_BYTEORDER_LOONGARCH_H
7 
8 #include "generic/rte_byteorder.h"
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
15 
16 #define rte_cpu_to_le_16(x) (x)
17 #define rte_cpu_to_le_32(x) (x)
18 #define rte_cpu_to_le_64(x) (x)
19 
20 #define rte_cpu_to_be_16(x) rte_bswap16(x)
21 #define rte_cpu_to_be_32(x) rte_bswap32(x)
22 #define rte_cpu_to_be_64(x) rte_bswap64(x)
23 
24 #define rte_le_to_cpu_16(x) (x)
25 #define rte_le_to_cpu_32(x) (x)
26 #define rte_le_to_cpu_64(x) (x)
27 
28 #define rte_be_to_cpu_16(x) rte_bswap16(x)
29 #define rte_be_to_cpu_32(x) rte_bswap32(x)
30 #define rte_be_to_cpu_64(x) rte_bswap64(x)
31 
32 #else /* RTE_BIG_ENDIAN */
33 #error "LoongArch not support big endian!"
34 #endif
35 
36 #ifdef __cplusplus
37 }
38 #endif
39 
40 #endif /* RTE_BYTEORDER_LOONGARCH_H */
41