34 #ifndef _RTE_BYTEORDER_H_ 35 #define _RTE_BYTEORDER_H_ 47 #ifdef RTE_EXEC_ENV_BSDAPP 48 #include <sys/endian.h> 58 #define RTE_BIG_ENDIAN 1 59 #define RTE_LITTLE_ENDIAN 2 60 #if defined __BYTE_ORDER__ 61 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 62 #define RTE_BYTE_ORDER RTE_BIG_ENDIAN 63 #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 64 #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN 66 #elif defined __BYTE_ORDER 67 #if __BYTE_ORDER == __BIG_ENDIAN 68 #define RTE_BYTE_ORDER RTE_BIG_ENDIAN 69 #elif __BYTE_ORDER == __LITTLE_ENDIAN 70 #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN 72 #elif defined __BIG_ENDIAN__ 73 #define RTE_BYTE_ORDER RTE_BIG_ENDIAN 74 #elif defined __LITTLE_ENDIAN__ 75 #define RTE_BYTE_ORDER RTE_LITTLE_ENDIAN 84 static inline uint16_t
85 rte_constant_bswap16(uint16_t x)
87 return (uint16_t)(((x & 0x00ffU) << 8) |
88 ((x & 0xff00U) >> 8));
97 static inline uint32_t
98 rte_constant_bswap32(uint32_t x)
100 return ((x & 0x000000ffUL) << 24) |
101 ((x & 0x0000ff00UL) << 8) |
102 ((x & 0x00ff0000UL) >> 8) |
103 ((x & 0xff000000UL) >> 24);
112 static inline uint64_t
113 rte_constant_bswap64(uint64_t x)
115 return ((x & 0x00000000000000ffULL) << 56) |
116 ((x & 0x000000000000ff00ULL) << 40) |
117 ((x & 0x0000000000ff0000ULL) << 24) |
118 ((x & 0x00000000ff000000ULL) << 8) |
119 ((x & 0x000000ff00000000ULL) >> 8) |
120 ((x & 0x0000ff0000000000ULL) >> 24) |
121 ((x & 0x00ff000000000000ULL) >> 40) |
122 ((x & 0xff00000000000000ULL) >> 56);
208 #ifdef RTE_FORCE_INTRINSICS 209 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) 210 #define rte_bswap16(x) __builtin_bswap16(x) 213 #define rte_bswap32(x) __builtin_bswap32(x) 215 #define rte_bswap64(x) __builtin_bswap64(x) static uint32_t rte_be_to_cpu_32(uint32_t x)
static uint16_t rte_bswap16(uint16_t _x)
static uint32_t rte_cpu_to_le_32(uint32_t x)
static uint16_t rte_cpu_to_le_16(uint16_t x)
static uint64_t rte_be_to_cpu_64(uint64_t x)
static uint32_t rte_bswap32(uint32_t x)
static uint16_t rte_cpu_to_be_16(uint16_t x)
static uint16_t rte_be_to_cpu_16(uint16_t x)
static uint64_t rte_cpu_to_be_64(uint64_t x)
static uint64_t rte_le_to_cpu_64(uint64_t x)
static uint64_t rte_bswap64(uint64_t x)
static uint32_t rte_le_to_cpu_32(uint32_t x)
static uint64_t rte_cpu_to_le_64(uint64_t x)
static uint16_t rte_le_to_cpu_16(uint16_t x)
static uint32_t rte_cpu_to_be_32(uint32_t x)