amino
Lightweight Robot Utility Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
endconv.h File Reference

Routines to convert numbers to different endian formats. More...

Go to the source code of this file.

Macros

#define AA_ENDCONV_MAKE_REVERSE(type, suffix)
 definer macro for a reverse expression function More...
 
#define AA_ENDCONV_MAKE_H_TO_LE(type, suffix)   static inline type aa_endconv_h_to_le_##suffix( type v ) { return v; }
 Make host to little-endian conversion function.
 
#define AA_ENDCONV_MAKE_H_TO_BE(type, suffix)
 Make host to big-endian conversion function. More...
 
#define AA_ENDCONV_MAKE_LE_TO_H(type, suffix)   static inline type aa_endconv_le_to_h_##suffix( type v ) { return v; }
 Make host to little-endian conversion function.
 
#define AA_ENDCONV_MAKE_BE_TO_H(type, suffix)
 Make host to big-endian conversion function. More...
 
#define AA_ENDCONV_MAKE_LDST_DEF(type, suffix)
 macro make to load/store function defs More...
 
#define AA_ENDCONV_MAKE_CONV_DEF(type, suffix)
 macro to make conversion function defs More...
 

Functions

static int64_t aa_endconv_ld_le_i64 (void *src)
 PROTOTYPES. More...
 
static void aa_endconv_st_le_i64 (void *dst, int64_t src)
 convert native to src to little-endian dst
 
static int64_t aa_endconv_ld_be_i64 (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_i64 (void *dst, int64_t src)
 convert native src to big-endian dst
 
static int64_t aa_endconv_h_to_le_i64 (int64_t i_host)
 convert native representation to little-endian
 
static int64_t aa_endconv_le_to_h_i64 (int64_t i_le)
 convert little-endian representation to native
 
static int64_t aa_endconv_h_to_be_i64 (int64_t i_host)
 convert native representation to big-endian
 
static int64_t aa_endconv_be_to_h_i64 (int64_t i_be)
 convert big-endian representation to native
 
static uint64_t aa_endconv_ld_le_u64 (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 uint64_t aa_endconv_ld_be_u64 (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_u64 (void *dst, uint64_t src)
 convert native src to big-endian dst
 
static uint64_t aa_endconv_h_to_le_u64 (uint64_t i_host)
 convert native representation to little-endian
 
static uint64_t aa_endconv_le_to_h_u64 (uint64_t i_le)
 convert little-endian representation to native
 
static uint64_t aa_endconv_h_to_be_u64 (uint64_t i_host)
 convert native representation to big-endian
 
static uint64_t aa_endconv_be_to_h_u64 (uint64_t i_be)
 convert big-endian representation to native
 
static int32_t aa_endconv_ld_le_i32 (void *src)
 Memory Load: convert little endian src to native type.
 
static void aa_endconv_st_le_i32 (void *dst, int32_t src)
 convert native to src to little-endian dst
 
static int32_t aa_endconv_ld_be_i32 (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_i32 (void *dst, int32_t src)
 convert native src to big-endian dst
 
static int32_t aa_endconv_h_to_le_i32 (int32_t i_host)
 convert native representation to little-endian
 
static int32_t aa_endconv_le_to_h_i32 (int32_t i_le)
 convert little-endian representation to native
 
static int32_t aa_endconv_h_to_be_i32 (int32_t i_host)
 convert native representation to big-endian
 
static int32_t aa_endconv_be_to_h_i32 (int32_t i_be)
 convert big-endian representation to native
 
static uint32_t aa_endconv_ld_le_u32 (void *src)
 Memory Load: convert little endian src to native type.
 
static void aa_endconv_st_le_u32 (void *dst, uint32_t src)
 convert native to src to little-endian dst
 
static uint32_t aa_endconv_ld_be_u32 (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_u32 (void *dst, uint32_t src)
 convert native src to big-endian dst
 
static uint32_t aa_endconv_h_to_le_u32 (uint32_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 uint32_t aa_endconv_h_to_be_u32 (uint32_t i_host)
 convert native representation to big-endian
 
static uint32_t aa_endconv_be_to_h_u32 (uint32_t i_be)
 convert big-endian representation to native
 
static int16_t aa_endconv_ld_le_i16 (void *src)
 Memory Load: convert little endian src to native type.
 
static void aa_endconv_st_le_i16 (void *dst, int16_t src)
 convert native to src to little-endian dst
 
static int16_t aa_endconv_ld_be_i16 (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_i16 (void *dst, int16_t src)
 convert native src to big-endian dst
 
static int16_t aa_endconv_h_to_le_i16 (int16_t i_host)
 convert native representation to little-endian
 
static int16_t aa_endconv_le_to_h_i16 (int16_t i_le)
 convert little-endian representation to native
 
static int16_t aa_endconv_h_to_be_i16 (int16_t i_host)
 convert native representation to big-endian
 
static int16_t aa_endconv_be_to_h_i16 (int16_t i_be)
 convert big-endian representation to native
 
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_u16 (void *dst, uint16_t src)
 convert native to src to little-endian dst
 
static uint16_t aa_endconv_ld_be_u16 (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 uint16_t aa_endconv_h_to_le_u16 (uint16_t i_host)
 convert native representation to little-endian
 
static uint16_t aa_endconv_le_to_h_u16 (uint16_t i_le)
 convert little-endian representation to native
 
static uint16_t aa_endconv_h_to_be_u16 (uint16_t i_host)
 convert native representation to big-endian
 
static uint16_t aa_endconv_be_to_h_u16 (uint16_t i_be)
 convert big-endian representation to native
 
static double aa_endconv_ld_le_d (void *src)
 Memory Load: convert little endian src to native type.
 
static void aa_endconv_st_le_d (void *dst, double src)
 convert native to src to little-endian dst
 
static double aa_endconv_ld_be_d (void *src)
 Memory Load: convert big-endian src to native.
 
static void aa_endconv_st_be_d (void *dst, double src)
 convert native src to big-endian dst
 
static float aa_endconv_ld_le_s (void *src)
 Memory Load: convert little endian src to native type.
 
static void aa_endconv_st_le_s (void *dst, float src)
 convert native to src to little-endian dst
 
static float aa_endconv_ld_be_s (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 void aa_endconv_reverse (void *dst, void *src, size_t len)
 copy src to dst in reverse byte order
 
static void aa_endconv_st_le (void *dst, void *src, size_t len)
 st src to dst with dst being little endian
 
static void aa_endconv_st_be (void *dst, void *src, size_t len)
 st src to dst with dst being big endian
 
 AA_ENDCONV_MAKE_LDST_DEF (int16_t, i16)
 define functions for 16-bit signed int
 
 AA_ENDCONV_MAKE_CONV_DEF (int16_t, i16)
 define functions for 16-bit signed int
 
 AA_ENDCONV_MAKE_LDST_DEF (uint16_t, u16)
 define functions for 16-bit unsigned int
 
 AA_ENDCONV_MAKE_CONV_DEF (uint16_t, u16)
 define functions for 16-bit unsigned int
 
 AA_ENDCONV_MAKE_LDST_DEF (int32_t, i32)
 define functions for 32-bit signed int
 
 AA_ENDCONV_MAKE_CONV_DEF (int32_t, i32)
 define functions for 32-bit signed int
 
 AA_ENDCONV_MAKE_LDST_DEF (uint32_t, u32)
 define functions for 32-bit unsigned int
 
 AA_ENDCONV_MAKE_CONV_DEF (uint32_t, u32)
 define functions for 32-bit unsigned int
 
 AA_ENDCONV_MAKE_LDST_DEF (int64_t, i64)
 define functions for 64-bit signed int
 
 AA_ENDCONV_MAKE_CONV_DEF (int64_t, i64)
 define functions for 64-bit signed int
 
 AA_ENDCONV_MAKE_LDST_DEF (uint64_t, u64)
 define functions for 64-bit unsigned int
 
 AA_ENDCONV_MAKE_CONV_DEF (uint64_t, u64)
 define functions for 64-bit unsigned int
 
 AA_ENDCONV_MAKE_LDST_DEF (double, d)
 define functions for 64-bit floating point
 
 AA_ENDCONV_MAKE_LDST_DEF (float, s)
 define functions for 32-bit floating point
 

Detailed Description

Routines to convert numbers to different endian formats.

Author
Neil Dantam

Definition in file endconv.h.

Macro Definition Documentation

#define AA_ENDCONV_MAKE_BE_TO_H (   type,
  suffix 
)
Value:
static inline type aa_endconv_be_to_h_##suffix( type v ) { \
return aa_endconv_reverse_##suffix( v ); \
};

Make host to big-endian conversion function.

Definition at line 285 of file endconv.h.

#define AA_ENDCONV_MAKE_CONV_DEF (   type,
  suffix 
)
Value:
AA_ENDCONV_MAKE_REVERSE( type, suffix ) \
AA_ENDCONV_MAKE_H_TO_LE( type, suffix ) \
AA_ENDCONV_MAKE_H_TO_BE( type, suffix ) \
AA_ENDCONV_MAKE_LE_TO_H( type, suffix ) \
AA_ENDCONV_MAKE_BE_TO_H( type, suffix ) \
#define AA_ENDCONV_MAKE_BE_TO_H(type, suffix)
Make host to big-endian conversion function.
Definition: endconv.h:285
#define AA_ENDCONV_MAKE_H_TO_BE(type, suffix)
Make host to big-endian conversion function.
Definition: endconv.h:276
#define AA_ENDCONV_MAKE_H_TO_LE(type, suffix)
Make host to little-endian conversion function.
Definition: endconv.h:273
#define AA_ENDCONV_MAKE_LE_TO_H(type, suffix)
Make host to little-endian conversion function.
Definition: endconv.h:282
#define AA_ENDCONV_MAKE_REVERSE(type, suffix)
definer macro for a reverse expression function
Definition: endconv.h:254

macro to make conversion function defs

Definition at line 325 of file endconv.h.

#define AA_ENDCONV_MAKE_H_TO_BE (   type,
  suffix 
)
Value:
static inline type aa_endconv_h_to_be_##suffix( type v ) { \
return aa_endconv_reverse_##suffix( v ); \
};

Make host to big-endian conversion function.

Definition at line 276 of file endconv.h.

#define AA_ENDCONV_MAKE_LDST_DEF (   type,
  suffix 
)
Value:
static inline void aa_endconv_st_le_##suffix( void *dst, type src ) { \
aa_endconv_st_le( dst, &src, sizeof(type) ); } \
static inline void aa_endconv_st_be_##suffix( void *dst, type src ) { \
aa_endconv_st_be( dst, &src, sizeof(type) ); } \
static inline type aa_endconv_ld_le_##suffix( void *src ) { \
type r; \
aa_endconv_st_le( &r, src, sizeof(type) ); \
return r;} \
static inline type aa_endconv_ld_be_##suffix( void *src ) { \
type r; \
aa_endconv_st_be( &r, src, sizeof(type) ); \
return r; } \
static void aa_endconv_st_le(void *dst, void *src, size_t len)
st src to dst with dst being little endian
Definition: endconv.h:224
static void aa_endconv_st_be(void *dst, void *src, size_t len)
st src to dst with dst being big endian
Definition: endconv.h:235

macro make to load/store function defs

Definition at line 311 of file endconv.h.

#define AA_ENDCONV_MAKE_REVERSE (   type,
  suffix 
)
Value:
static inline type aa_endconv_reverse_##suffix( type x ) { \
type y = 0; \
type v; \
type j; \
size_t i; \
for( i = 0 ; i < 8*sizeof(type); i+=8 ) { \
j = (type) (8*sizeof(type) - i - 8); \
v = (type) (((x >> i) & 0xff) << j); \
y |= v; \
} \
return y; \
};

definer macro for a reverse expression function

Definition at line 254 of file endconv.h.

Function Documentation

static int64_t aa_endconv_ld_le_i64 ( void *  src)
inlinestatic

PROTOTYPES.

Memory Load: convert little endian src to native type