xref: /dpdk/lib/eal/arm/include/rte_byteorder.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015 RehiveTech. All rights reserved.
3  */
4 
5 #ifndef _RTE_BYTEORDER_ARM_H_
6 #define _RTE_BYTEORDER_ARM_H_
7 
8 #ifndef RTE_FORCE_INTRINSICS
9 #  error Platform must be built with RTE_FORCE_INTRINSICS
10 #endif
11 
12 #include <stdint.h>
13 #include <rte_common.h>
14 #include "generic/rte_byteorder.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /* ARM architecture is bi-endian (both big and little). */
21 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
22 
23 #define rte_cpu_to_le_16(x) (x)
24 #define rte_cpu_to_le_32(x) (x)
25 #define rte_cpu_to_le_64(x) (x)
26 
27 #define rte_cpu_to_be_16(x) rte_bswap16(x)
28 #define rte_cpu_to_be_32(x) rte_bswap32(x)
29 #define rte_cpu_to_be_64(x) rte_bswap64(x)
30 
31 #define rte_le_to_cpu_16(x) (x)
32 #define rte_le_to_cpu_32(x) (x)
33 #define rte_le_to_cpu_64(x) (x)
34 
35 #define rte_be_to_cpu_16(x) rte_bswap16(x)
36 #define rte_be_to_cpu_32(x) rte_bswap32(x)
37 #define rte_be_to_cpu_64(x) rte_bswap64(x)
38 
39 #else /* RTE_BIG_ENDIAN */
40 
41 #define rte_cpu_to_le_16(x) rte_bswap16(x)
42 #define rte_cpu_to_le_32(x) rte_bswap32(x)
43 #define rte_cpu_to_le_64(x) rte_bswap64(x)
44 
45 #define rte_cpu_to_be_16(x) (x)
46 #define rte_cpu_to_be_32(x) (x)
47 #define rte_cpu_to_be_64(x) (x)
48 
49 #define rte_le_to_cpu_16(x) rte_bswap16(x)
50 #define rte_le_to_cpu_32(x) rte_bswap32(x)
51 #define rte_le_to_cpu_64(x) rte_bswap64(x)
52 
53 #define rte_be_to_cpu_16(x) (x)
54 #define rte_be_to_cpu_32(x) (x)
55 #define rte_be_to_cpu_64(x) (x)
56 #endif
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif /* _RTE_BYTEORDER_ARM_H_ */
63