|
|
|
@ -34,8 +34,8 @@ extern "C" {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[2];
|
|
|
|
|
uint16_t u16;
|
|
|
|
|
uint8_t u8[2]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16; /**< 16 bit representation */
|
|
|
|
|
} le_uint16_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -44,10 +44,10 @@ typedef union __attribute__((packed)) {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[4];
|
|
|
|
|
uint16_t u16[2];
|
|
|
|
|
uint32_t u32;
|
|
|
|
|
le_uint16_t l16[2];
|
|
|
|
|
uint8_t u8[4]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16[2]; /**< 16 bit representation */
|
|
|
|
|
uint32_t u32; /**< 32 bit representation */
|
|
|
|
|
le_uint16_t l16[2]; /**< little endian 16 bit representation */
|
|
|
|
|
} le_uint32_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -56,12 +56,12 @@ typedef union __attribute__((packed)) {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[8];
|
|
|
|
|
uint16_t u16[4];
|
|
|
|
|
uint32_t u32[2];
|
|
|
|
|
uint64_t u64;
|
|
|
|
|
le_uint16_t l16[4];
|
|
|
|
|
le_uint32_t l32[2];
|
|
|
|
|
uint8_t u8[8]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16[4]; /**< 16 bit representation */
|
|
|
|
|
uint32_t u32[2]; /**< 32 bit representation */
|
|
|
|
|
uint64_t u64; /**< 64 bit representation */
|
|
|
|
|
le_uint16_t l16[4]; /**< little endian 16 bit representation */
|
|
|
|
|
le_uint32_t l32[2]; /**< little endian 32 bit representation */
|
|
|
|
|
} le_uint64_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -70,8 +70,8 @@ typedef union __attribute__((packed)) {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[2];
|
|
|
|
|
uint16_t u16;
|
|
|
|
|
uint8_t u8[2]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16; /**< 16 bit representation */
|
|
|
|
|
} be_uint16_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -80,10 +80,10 @@ typedef union __attribute__((packed)) {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[4];
|
|
|
|
|
uint16_t u16[2];
|
|
|
|
|
uint32_t u32;
|
|
|
|
|
be_uint16_t b16[2];
|
|
|
|
|
uint8_t u8[4]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16[2]; /**< 16 bit representation */
|
|
|
|
|
uint32_t u32; /**< 32 bit representation */
|
|
|
|
|
be_uint16_t b16[2]; /**< big endian 16 bit representation */
|
|
|
|
|
} be_uint32_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -92,16 +92,27 @@ typedef union __attribute__((packed)) {
|
|
|
|
|
* between different byte orders at compile time.
|
|
|
|
|
*/
|
|
|
|
|
typedef union __attribute__((packed)) {
|
|
|
|
|
uint8_t u8[8];
|
|
|
|
|
uint16_t u16[4];
|
|
|
|
|
uint32_t u32[2];
|
|
|
|
|
uint64_t u64;
|
|
|
|
|
be_uint16_t b16[4];
|
|
|
|
|
be_uint32_t b32[2];
|
|
|
|
|
uint8_t u8[8]; /**< 8 bit representation */
|
|
|
|
|
uint16_t u16[4]; /**< 16 bit representation */
|
|
|
|
|
uint32_t u32[2]; /**< 32 bit representation */
|
|
|
|
|
uint64_t u64; /**< 64 bit representation */
|
|
|
|
|
be_uint16_t b16[4]; /**< big endian 16 bit representation */
|
|
|
|
|
be_uint32_t b32[2]; /**< big endian 32 bit representation */
|
|
|
|
|
} be_uint64_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A 16 bit integer in network byte order.
|
|
|
|
|
*/
|
|
|
|
|
typedef be_uint16_t network_uint16_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A 32 bit integer in network byte order.
|
|
|
|
|
*/
|
|
|
|
|
typedef be_uint32_t network_uint32_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A 64 bit integer in network byte order.
|
|
|
|
|
*/
|
|
|
|
|
typedef be_uint64_t network_uint64_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -272,6 +283,9 @@ static inline le_uint64_t byteorder_btolll(be_uint64_t v)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Swaps the byteorder according to the endianess
|
|
|
|
|
*/
|
|
|
|
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
|
|
|
# define _byteorder_swap(V, T) (byteorder_swap##T((V)))
|
|
|
|
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
|
|
|