0.3.1
Endianness

Macros

#define cpu_htobe16(x)   ((uint16_t)(x))
 Convert from host byte order to big-endian order.
 
#define cpu_htole16(x)   cpu_bswap16((x))
 Convert from host byte order to little-endian order.
 
#define cpu_be16toh(x)   ((uint16_t)(x))
 Convert from big-endian order to host byte order.
 
#define cpu_le16toh(x)   cpu_bswap16((x))
 Convert from little-endian order to host byte order.
 
#define cpu_htobe32(x)   ((uint32_t)(x))
 Convert from host byte order to big-endian order.
 
#define cpu_htole32(x)   cpu_bswap32((x))
 Convert from host byte order to little-endian order.
 
#define cpu_be32toh(x)   ((uint32_t)(x))
 Convert from big-endian order to host byte order.
 
#define cpu_le32toh(x)   cpu_bswap32((x))
 Convert from little-endian order to host byte order.
 

Functions

static uint16_t cpu_bswap16 (uint16_t x)
 Swap the upper and lower bytes of a 2-byte value.
 
static uint32_t cpu_bswap32 (uint32_t x)
 Swap the upper and lower 2-bytes of a 4-byte value.
 

Detailed Description

Description goes here.

Function Documentation

◆ cpu_bswap16()

static uint16_t cpu_bswap16 ( uint16_t  x)
inlinestatic

Swap the upper and lower bytes of a 2-byte value.

The __builtin_bswap16() function that GCC emits does not use the swap.b instruction.

Parameters
xValue to be swapped.
Returns
Swapped value.

◆ cpu_bswap32()

static uint32_t cpu_bswap32 ( uint32_t  x)
inlinestatic

Swap the upper and lower 2-bytes of a 4-byte value.

The __builtin_bswap32() function that GCC emits does not use the swap.w instruction.

Parameters
xValue to be swapped.
Returns
Swapped value.