38 #ifndef included_clib_byte_order_h 39 #define included_clib_byte_order_h 43 #if (__BYTE_ORDER__)==( __ORDER_LITTLE_ENDIAN__) 44 #define CLIB_ARCH_IS_BIG_ENDIAN (0) 45 #define CLIB_ARCH_IS_LITTLE_ENDIAN (1) 48 #define CLIB_ARCH_IS_BIG_ENDIAN (1) 49 #define CLIB_ARCH_IS_LITTLE_ENDIAN (0) 53 #define clib_arch_is_big_endian CLIB_ARCH_IS_BIG_ENDIAN 54 #define clib_arch_is_little_endian CLIB_ARCH_IS_LITTLE_ENDIAN 59 return __builtin_bswap16 (x);
71 return __builtin_bswap32 (x);
83 return __builtin_bswap64 (x);
95 clib_host_to_##sex##_##type (type x) \ 97 if (! clib_arch_is_##sex##_endian) \ 98 x = clib_byte_swap_##type (x); \ 103 clib_host_to_##sex##_mem_##type (type * x) \ 106 return clib_host_to_##sex##_##type (v); \ 110 clib_host_to_##sex##_unaligned_mem_##type (type * x) \ 112 type v = clib_mem_unaligned (x, type); \ 113 return clib_host_to_##sex##_##type (v); \ 118 clib_##sex##_to_host_##type (type x) \ 119 { return clib_host_to_##sex##_##type (x); } \ 122 clib_##sex##_to_host_mem_##type (type * x) \ 123 { return clib_host_to_##sex##_mem_##type (x); } \ 126 clib_##sex##_to_host_unaligned_mem_##type (type * x) \ 127 { return clib_host_to_##sex##_unaligned_mem_##type (x); } 142 clib_net_to_host_##type (type x) \ 143 { return clib_big_to_host_##type (x); } \ 146 clib_net_to_host_mem_##type (type * x) \ 147 { return clib_big_to_host_mem_##type (x); } \ 150 clib_net_to_host_unaligned_mem_##type (type * x) \ 151 { return clib_big_to_host_unaligned_mem_##type (x); } \ 154 clib_host_to_net_##type (type x) \ 155 { return clib_host_to_big_##type (x); } \ 158 clib_host_to_net_mem_##type (type * x) \ 159 { return clib_host_to_big_mem_##type (x); } \ 162 clib_host_to_net_unaligned_mem_##type (type * x) \ 163 { return clib_host_to_big_unaligned_mem_##type (x); }
static u32 clib_byte_swap_u32(u32 x)
static i64 clib_byte_swap_i64(i64 x)
static i32 clib_byte_swap_i32(i32 x)
static i16 clib_byte_swap_i16(i16 x)
static u64 clib_byte_swap_u64(u64 x)
static f32 clib_net_to_host_f32(f32 x)
static f64 clib_net_to_host_f64(f64 x)
static f64 clib_host_to_net_f64(f64 x)
static f32 clib_host_to_net_f32(f32 x)
static u16 clib_byte_swap_u16(u16 x)