214 for( i = 0; i < len; i ++ ) {
215 size_t j = len - i - 1;
216 uint8_t s = ((uint8_t*)src)[j];
218 ((uint8_t*)dst)[i] = s;
225 #if __BYTE_ORDER == __LITTLE_ENDIAN
226 memcpy( dst, src, len );
227 #elif __BYTE_ORDER == __BIG_ENDIAN
230 #error "Unknown Endian Convention"
236 #if __BYTE_ORDER == __LITTLE_ENDIAN
238 #elif __BYTE_ORDER == __BIG_ENDIAN
239 memcpy( dst, src, len );
241 #error "Unknown Endian Convention"
254 #define AA_ENDCONV_MAKE_REVERSE( type, suffix ) \
255 static inline type aa_endconv_reverse_##suffix( type x ) { \
260 for( i = 0 ; i < 8*sizeof(type); i+=8 ) { \
261 j = (type) (8*sizeof(type) - i - 8); \
262 v = (type) (((x >> i) & 0xff) << j); \
270 #if __BYTE_ORDER == __LITTLE_ENDIAN
273 #define AA_ENDCONV_MAKE_H_TO_LE( type, suffix ) \
274 static inline type aa_endconv_h_to_le_##suffix( type v ) { return v; }
275 #define AA_ENDCONV_MAKE_H_TO_BE( type, suffix ) \
277 static inline type aa_endconv_h_to_be_##suffix( type v ) { \
278 return aa_endconv_reverse_##suffix( v ); \
282 #define AA_ENDCONV_MAKE_LE_TO_H( type, suffix ) \
283 static inline type aa_endconv_le_to_h_##suffix( type v ) { return v; }
284 #define AA_ENDCONV_MAKE_BE_TO_H( type, suffix ) \
286 static inline type aa_endconv_be_to_h_##suffix( type v ) { \
287 return aa_endconv_reverse_##suffix( v ); \
290 #elif __BYTE_ORDER == __BIG_ENDIAN
292 #define AA_ENDCONV_MAKE_H_TO_LE( type, suffix ) \
293 static inline type aa_endconv_h_to_le_##suffix( type v ) { \
294 return aa_endconv_reverse_##suffix( v ); \
296 #define AA_ENDCONV_MAKE_H_TO_BE( type, suffix ) \
297 static inline type aa_endconv_h_to_le_##suffix( type v ) { return v; }
299 #define AA_ENDCONV_MAKE_LE_TO_H( type, suffix ) \
300 static inline type aa_endconv_le_to_h_##suffix( type v ) { \
301 return aa_endconv_reverse_##suffix( v ); \
303 #define AA_ENDCONV_MAKE_BE_TO_H( type, suffix ) \
304 static inline type aa_endconv_be_to_h_##suffix( type v ) { return v; }
307 #error "Unknown Endian Convention"
311 #define AA_ENDCONV_MAKE_LDST_DEF(type,suffix) \
312 static inline void aa_endconv_st_le_##suffix( void *dst, type src ) { \
313 aa_endconv_st_le( dst, &src, sizeof(type) ); } \
314 static inline void aa_endconv_st_be_##suffix( void *dst, type src ) { \
315 aa_endconv_st_be( dst, &src, sizeof(type) ); } \
316 static inline type aa_endconv_ld_le_##suffix( void *src ) { \
318 aa_endconv_st_le( &r, src, sizeof(type) ); \
320 static inline type aa_endconv_ld_be_##suffix( void *src ) { \
322 aa_endconv_st_be( &r, src, sizeof(type) ); \
324 #define AA_ENDCONV_MAKE_CONV_DEF(type,suffix) \
326 AA_ENDCONV_MAKE_REVERSE( type, suffix ) \
327 AA_ENDCONV_MAKE_H_TO_LE( type, suffix ) \
328 AA_ENDCONV_MAKE_H_TO_BE( type, suffix ) \
329 AA_ENDCONV_MAKE_LE_TO_H( type, suffix ) \
330 AA_ENDCONV_MAKE_BE_TO_H( type, suffix ) \
static int16_t aa_endconv_le_to_h_i16(int16_t i_le)
convert little-endian representation to native
static void aa_endconv_st_be_i32(void *dst, int32_t src)
convert native src to big-endian dst
static uint64_t aa_endconv_ld_le_u64(void *src)
Memory Load: convert little endian src to native type.
static int32_t aa_endconv_ld_le_i32(void *src)
Memory Load: convert little endian src to native type.
static int32_t aa_endconv_be_to_h_i32(int32_t i_be)
convert big-endian representation to native
static uint64_t aa_endconv_le_to_h_u64(uint64_t i_le)
convert little-endian representation to native
static void aa_endconv_st_be_u64(void *dst, uint64_t src)
convert native src to big-endian dst
static float aa_endconv_ld_be_s(void *src)
Memory Load: convert big-endian src to native.
static void aa_endconv_st_le_u32(void *dst, uint32_t src)
convert native to src to little-endian dst
static int16_t aa_endconv_h_to_be_i16(int16_t i_host)
convert native representation to big-endian
static uint32_t aa_endconv_h_to_le_u32(uint32_t i_host)
convert native representation to little-endian
#define AA_ENDCONV_MAKE_LDST_DEF(type, suffix)
macro make to load/store function defs
#define AA_ENDCONV_MAKE_CONV_DEF(type, suffix)
macro to make conversion function defs
static int64_t aa_endconv_ld_le_i64(void *src)
PROTOTYPES.
static int16_t aa_endconv_be_to_h_i16(int16_t i_be)
convert big-endian representation to native
static float aa_endconv_ld_le_s(void *src)
Memory Load: convert little endian src to native type.
static void aa_endconv_st_le(void *dst, void *src, size_t len)
st src to dst with dst being little endian
static int16_t aa_endconv_ld_be_i16(void *src)
Memory Load: convert big-endian src to native.
static void aa_endconv_st_be_s(void *dst, float src)
convert native src to big-endian dst
static uint64_t aa_endconv_ld_be_u64(void *src)
Memory Load: convert big-endian src to native.
static uint32_t aa_endconv_ld_be_u32(void *src)
Memory Load: convert big-endian src to native.
static void aa_endconv_st_be_u16(void *dst, uint16_t src)
convert native src to big-endian dst
static double aa_endconv_ld_le_d(void *src)
Memory Load: convert little endian src to native type.
static uint64_t aa_endconv_h_to_be_u64(uint64_t i_host)
convert native representation to big-endian
static double aa_endconv_ld_be_d(void *src)
Memory Load: convert big-endian src to native.
static uint16_t aa_endconv_le_to_h_u16(uint16_t i_le)
convert little-endian representation to native
static int32_t aa_endconv_le_to_h_i32(int32_t i_le)
convert little-endian representation to native
static int64_t aa_endconv_ld_be_i64(void *src)
Memory Load: convert big-endian src to native.
static int64_t aa_endconv_le_to_h_i64(int64_t i_le)
convert little-endian representation to native
static void aa_endconv_st_be_d(void *dst, double src)
convert native src to big-endian dst
static uint16_t aa_endconv_ld_be_u16(void *src)
Memory Load: convert big-endian src to native.
static int16_t aa_endconv_h_to_le_i16(int16_t i_host)
convert native representation to little-endian
static uint32_t aa_endconv_le_to_h_u32(uint32_t i_le)
convert little-endian representation to native
static int64_t aa_endconv_be_to_h_i64(int64_t i_be)
convert big-endian representation to native
static int64_t aa_endconv_h_to_le_i64(int64_t i_host)
convert native representation to little-endian
static int32_t aa_endconv_h_to_be_i32(int32_t i_host)
convert native representation to big-endian
static int32_t aa_endconv_h_to_le_i32(int32_t i_host)
convert native representation to little-endian
static void aa_endconv_st_be_i16(void *dst, int16_t src)
convert native src to big-endian dst
static void aa_endconv_st_le_i64(void *dst, int64_t src)
convert native to src to little-endian dst
static void aa_endconv_st_le_i16(void *dst, int16_t src)
convert native to src to little-endian dst
static void aa_endconv_st_be_u32(void *dst, uint32_t src)
convert native src to big-endian dst
static uint16_t aa_endconv_h_to_be_u16(uint16_t i_host)
convert native representation to big-endian
static int16_t aa_endconv_ld_le_i16(void *src)
Memory Load: convert little endian src to native type.
static void aa_endconv_st_be(void *dst, void *src, size_t len)
st src to dst with dst being big endian
static void aa_endconv_st_le_s(void *dst, float src)
convert native to src to little-endian dst
static uint16_t aa_endconv_ld_le_u16(void *src)
Memory Load: convert little endian src to native type.
static void aa_endconv_st_le_u64(void *dst, uint64_t src)
convert native to src to little-endian dst
static uint32_t aa_endconv_ld_le_u32(void *src)
Memory Load: convert little endian src to native type.
static int32_t aa_endconv_ld_be_i32(void *src)
Memory Load: convert big-endian src to native.
static void aa_endconv_st_le_i32(void *dst, int32_t src)
convert native to src to little-endian dst
static int64_t aa_endconv_h_to_be_i64(int64_t i_host)
convert native representation to big-endian
static uint16_t aa_endconv_h_to_le_u16(uint16_t i_host)
convert native representation to little-endian
static void aa_endconv_st_be_i64(void *dst, int64_t src)
convert native src to big-endian dst
static void aa_endconv_st_le_u16(void *dst, uint16_t src)
convert native to src to little-endian dst
static uint16_t aa_endconv_be_to_h_u16(uint16_t i_be)
convert big-endian representation to native
static uint32_t aa_endconv_be_to_h_u32(uint32_t i_be)
convert big-endian representation to native
static void aa_endconv_reverse(void *dst, void *src, size_t len)
copy src to dst in reverse byte order
static uint32_t aa_endconv_h_to_be_u32(uint32_t i_host)
convert native representation to big-endian
static uint64_t aa_endconv_h_to_le_u64(uint64_t i_host)
convert native representation to little-endian
static uint64_t aa_endconv_be_to_h_u64(uint64_t i_be)
convert big-endian representation to native
static void aa_endconv_st_le_d(void *dst, double src)
convert native to src to little-endian dst