38typedef union __attribute__((packed)) {
48typedef union __attribute__((packed)) {
60typedef union __attribute__((packed)) {
74typedef union __attribute__((packed)) {
84typedef union __attribute__((packed)) {
96typedef union __attribute__((packed)) {
348static inline uint16_t
htons(uint16_t v);
356static inline uint32_t
htonl(uint32_t v);
364static inline uint64_t
htonll(uint64_t v);
372static inline uint16_t
ntohs(uint16_t v);
380static inline uint32_t
ntohl(uint32_t v);
388static inline uint64_t
ntohll(uint64_t v);
394 return __builtin_bswap16(v);
399 return __builtin_bswap32(v);
404 return __builtin_bswap64(v);
521static inline uint16_t
htons(uint16_t v)
526static inline uint32_t
htonl(uint32_t v)
536static inline uint16_t
ntohs(uint16_t v)
541static inline uint32_t
ntohl(uint32_t v)
569 memcpy(buf, &val,
sizeof(val));
575 memcpy(buf, &val,
sizeof(val));
581 memcpy(buf, &val,
sizeof(val));
584static inline uint16_t byteorder_lebuftohs(
const uint8_t *buf)
589static inline uint32_t byteorder_lebuftohl(
const uint8_t *buf)
594static inline uint64_t byteorder_lebuftohll(
const uint8_t *buf)
599static inline void byteorder_htolebufs(uint8_t *buf, uint16_t val)
602 memcpy(buf, &val,
sizeof(val));
605static inline void byteorder_htolebufl(uint8_t *buf, uint32_t val)
608 memcpy(buf, &val,
sizeof(val));
611static inline void byteorder_htolebufll(uint8_t *buf, uint64_t val)
614 memcpy(buf, &val,
sizeof(val));
be_uint32_t network_uint32_t
A 32 bit integer in network byte order.
static uint64_t ntohll(uint64_t v)
Convert from network byte order to host byte order, 64 bit.
static uint32_t byteorder_ntohl(network_uint32_t v)
Convert from network byte order to host byte order, 32 bit.
static uint16_t ntohs(uint16_t v)
Convert from network byte order to host byte order, 16 bit.
static void byteorder_htobebufs(uint8_t *buf, uint16_t val)
Write a host byte order encoded unsigned integer as big endian encoded value into a buffer,...
static uint16_t byteorder_ltohs(le_uint16_t v)
Convert from little endian to host byte order, 16 bit.
static uint64_t byteorder_ltohll(le_uint64_t v)
Convert from little endian to host byte order, 64 bit.
static le_uint64_t byteorder_btolll(be_uint64_t v)
Convert from big endian to little endian, 64 bit.
static uint64_t byteorder_swapll(uint64_t v)
Swap byte order, 64 bit.
static be_uint32_t byteorder_ltobl(le_uint32_t v)
Convert from little endian to big endian, 32 bit.
static network_uint64_t byteorder_htonll(uint64_t v)
Convert from host byte order to network byte order, 64 bit.
static uint64_t byteorder_ntohll(network_uint64_t v)
Convert from network byte order to host byte order, 64 bit.
static uint64_t byteorder_bebuftohll(const uint8_t *buf)
Read a big endian encoded unsigned integer from a buffer into host byte order encoded variable,...
static uint32_t byteorder_ltohl(le_uint32_t v)
Convert from little endian to host byte order, 32 bit.
be_uint16_t network_uint16_t
A 16 bit integer in network byte order.
static void byteorder_htobebufll(uint8_t *buf, uint64_t val)
Write a host byte order encoded unsigned integer as big endian encoded value into a buffer,...
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
static uint64_t htonll(uint64_t v)
Convert from host byte order to network byte order, 64 bit.
static be_uint16_t byteorder_ltobs(le_uint16_t v)
Convert from little endian to big endian, 16 bit.
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
static uint32_t htonl(uint32_t v)
Convert from host byte order to network byte order, 32 bit.
static uint16_t byteorder_bebuftohs(const uint8_t *buf)
Read a big endian encoded unsigned integer from a buffer into host byte order encoded variable,...
static le_uint64_t byteorder_htolll(uint64_t v)
Convert from host byte order to little endian, 64 bit.
static le_uint32_t byteorder_btoll(be_uint32_t v)
Convert from big endian to little endian, 32 bit.
static le_uint16_t byteorder_btols(be_uint16_t v)
Convert from big endian to little endian, 16 bit.
static uint16_t byteorder_swaps(uint16_t v)
Swap byte order, 16 bit.
static le_uint16_t byteorder_htols(uint16_t v)
Convert from host byte order to little endian, 16 bit.
static void byteorder_htobebufl(uint8_t *buf, uint32_t val)
Write a host byte order encoded unsigned integer as big endian encoded value into a buffer,...
static be_uint64_t byteorder_ltobll(le_uint64_t v)
Convert from little endian to big endian, 64 bit.
static uint32_t byteorder_swapl(uint32_t v)
Swap byte order, 32 bit.
be_uint64_t network_uint64_t
A 64 bit integer in network byte order.
static le_uint32_t byteorder_htoll(uint32_t v)
Convert from host byte order to little endian, 32 bit.
static uint32_t ntohl(uint32_t v)
Convert from network byte order to host byte order, 32 bit.
static uint32_t byteorder_bebuftohl(const uint8_t *buf)
Read a big endian encoded unsigned integer from a buffer into host byte order encoded variable,...
static network_uint32_t byteorder_htonl(uint32_t v)
Convert from host byte order to network byte order, 32 bit.
static uint16_t htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
libc header for endian conversion
uint16_t be16toh(uint16_t big_endian_16bits)
big endian to host, 16 bit
uint16_t htobe16(uint16_t host_16bits)
host to big endian, 16 bit
uint32_t le32toh(uint32_t little_endian_32bits)
little endian to host, 32 bit
uint32_t htobe32(uint32_t host_32bits)
host to big endian, 32 bit
uint16_t le16toh(uint16_t little_endian_16bits)
little endian to host, 16 bit
uint64_t htobe64(uint64_t host_64bits)
host to big endian, 64 bit
uint64_t be64toh(uint64_t big_endian_64bits)
big endian to host, 64 bit
uint32_t be32toh(uint32_t big_endian_32bits)
big endian to host, 32 bit
uint64_t htole64(uint64_t host_64bits)
host to little endian, 64 bit
uint32_t htole32(uint32_t host_32bits)
host to little endian, 32 bit
uint16_t htole16(uint16_t host_16bits)
host to little endian, 16 bit
uint64_t le64toh(uint64_t little_endian_64bits)
little endian to host, 64 bit
static uint16_t unaligned_get_u16(const void *ptr)
Get uint16_t from possibly unaligned pointer.
static uint64_t unaligned_get_u64(const void *ptr)
Get uint64_t from possibly unaligned pointer.
static uint32_t unaligned_get_u32(const void *ptr)
Get uint32_t from possibly unaligned pointer.
Unaligned but safe memory access functions.
A 16 bit integer in big endian aka network byte order.
uint16_t u16
16 bit representation
A 32 bit integer in big endian aka network byte order.
uint32_t u32
32 bit representation
A 64 bit integer in big endian aka network byte order.
uint64_t u64
64 bit representation
A 16 bit integer in little endian.
uint16_t u16
16 bit representation
A 32 bit integer in little endian.
uint32_t u32
32 bit representation
A 64 bit integer in little endian.
uint64_t u64
64 bit representation