|
|
|
@ -210,7 +210,7 @@ static inline uint64_t byteorder_swapll(uint64_t v);
|
|
|
|
|
/* **************************** IMPLEMENTATION ***************************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t byteorder_swaps(uint16_t v)
|
|
|
|
|
static inline uint16_t byteorder_swaps(uint16_t v)
|
|
|
|
|
{
|
|
|
|
|
#ifndef MODULE_MSP430_COMMON
|
|
|
|
|
return __builtin_bswap16(v);
|
|
|
|
@ -223,47 +223,47 @@ uint16_t byteorder_swaps(uint16_t v)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t byteorder_swapl(uint32_t v)
|
|
|
|
|
static inline uint32_t byteorder_swapl(uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
return __builtin_bswap32(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t byteorder_swapll(uint64_t v)
|
|
|
|
|
static inline uint64_t byteorder_swapll(uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
return __builtin_bswap64(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
be_uint16_t byteorder_ltobs(le_uint16_t v)
|
|
|
|
|
static inline be_uint16_t byteorder_ltobs(le_uint16_t v)
|
|
|
|
|
{
|
|
|
|
|
be_uint16_t result = { .u16 = byteorder_swaps(v.u16) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
be_uint32_t byteorder_ltobl(le_uint32_t v)
|
|
|
|
|
static inline be_uint32_t byteorder_ltobl(le_uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
be_uint32_t result = { .u32 = byteorder_swapl(v.u32) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
be_uint64_t byteorder_ltobll(le_uint64_t v)
|
|
|
|
|
static inline be_uint64_t byteorder_ltobll(le_uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
be_uint64_t result = { .u64 = byteorder_swapll(v.u64) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
le_uint16_t byteorder_btols(be_uint16_t v)
|
|
|
|
|
static inline le_uint16_t byteorder_btols(be_uint16_t v)
|
|
|
|
|
{
|
|
|
|
|
le_uint16_t result = { .u16 = byteorder_swaps(v.u16) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
le_uint32_t byteorder_btoll(be_uint32_t v)
|
|
|
|
|
static inline le_uint32_t byteorder_btoll(be_uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
le_uint32_t result = { .u32 = byteorder_swapl(v.u32) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
le_uint64_t byteorder_btolll(be_uint64_t v)
|
|
|
|
|
static inline le_uint64_t byteorder_btolll(be_uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
le_uint64_t result = { .u64 = byteorder_swapll(v.u64) };
|
|
|
|
|
return result;
|
|
|
|
@ -277,35 +277,35 @@ le_uint64_t byteorder_btolll(be_uint64_t v)
|
|
|
|
|
# error "Byte order is neither little nor big!"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
network_uint16_t byteorder_htons(uint16_t v)
|
|
|
|
|
static inline network_uint16_t byteorder_htons(uint16_t v)
|
|
|
|
|
{
|
|
|
|
|
network_uint16_t result = { .u16 = _byteorder_swap(v, s) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
network_uint32_t byteorder_htonl(uint32_t v)
|
|
|
|
|
static inline network_uint32_t byteorder_htonl(uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
network_uint32_t result = { .u32 = _byteorder_swap(v, l) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
network_uint64_t byteorder_htonll(uint64_t v)
|
|
|
|
|
static inline network_uint64_t byteorder_htonll(uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
network_uint64_t result = { .u64 = _byteorder_swap(v, ll) };
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t byteorder_ntohs(network_uint16_t v)
|
|
|
|
|
static inline uint16_t byteorder_ntohs(network_uint16_t v)
|
|
|
|
|
{
|
|
|
|
|
return _byteorder_swap(v.u16, s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t byteorder_ntohl(network_uint32_t v)
|
|
|
|
|
static inline uint32_t byteorder_ntohl(network_uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
return _byteorder_swap(v.u32, l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t byteorder_ntohll(network_uint64_t v)
|
|
|
|
|
static inline uint64_t byteorder_ntohll(network_uint64_t v)
|
|
|
|
|
{
|
|
|
|
|
return _byteorder_swap(v.u64, ll);
|
|
|
|
|
}
|
|
|
|
|