libusual  0.1
usual/endian.h File Reference

Endianess conversion, convert integers to bytes. More...

Defines

Convert host-endian int to BE/LE.
#define htobe16(x)
 Convert native 16-bit int to big-endian.
#define htobe32(x)
 Convert native 32-bit int to big-endian.
#define htobe64(x)
 Convert native 64-bit int to big-endian.
#define htole16(x)
 Convert native 16-bit int to little-endian.
#define htole32(x)
 Convert native 32-bit int to little-endian.
#define htole64(x)
 Convert native 64-bit int to little-endian.
#define be16toh(x)
 Convert big-endian 16-bit int to host-endian.
#define be32toh(x)
 Convert big-endian 32-bit int to host-endian.
#define be64toh(x)
 Convert big-endian 64-bit int to host-endian.
#define le16toh(x)
 Convert little-endian 64-bit int to host-endian.
#define le32toh(x)
 Convert little-endian 64-bit int to host-endian.
#define le64toh(x)
 Convert little-endian 64-bit int to host-endian.

Functions

Always swap.
static uint16_t bswap16 (uint16_t x)
 Swap 16-bit int.
static uint32_t bswap32 (uint32_t x)
 Swap 32-bit int.
static uint64_t bswap64 (uint64_t x)
 Swap 64-bit int.
Read integer values from memory and convert to host format.
static uint16_t be16dec (const void *p)
 Read big-endian 16-bit int from memory.
static uint32_t be32dec (const void *p)
 Read big-endian 32-bit int from memory.
static uint64_t be64dec (const void *p)
 Read big-endian 64-bit int from memory.
static uint16_t le16dec (const void *p)
 Read little-endian 16-bit int from memory.
static uint32_t le32dec (const void *p)
 Read little-endian 32-bit int from memory.
static uint64_t le64dec (const void *p)
 Read little-endian 64-bit int from memory.
static uint16_t h16dec (const void *p)
 Read host-endian 16-bit int from memory.
static uint32_t h32dec (const void *p)
 Read host-endian 32-bit int from memory.
static uint64_t h64dec (const void *p)
 Read host-endian 64-bit int from memory.
Convert host value to LE/BE and write to memory
static void be16enc (void *p, uint16_t x)
 Write big-endian 16-bit int to memory.
static void be32enc (void *p, uint32_t x)
 Write big-endian 32-bit int to memory.
static void be64enc (void *p, uint64_t x)
 Write big-endian 64-bit int to memory.
static void le16enc (void *p, uint16_t x)
 Write little-endian 16-bit int to memory.
static void le32enc (void *p, uint32_t x)
 Write little-endian 32-bit int to memory.
static void le64enc (void *p, uint64_t x)
 Write little-endian 64-bit int to memory.
static void h16enc (void *p, uint16_t x)
 Write host-endian 16-bit int to memory.
static void h32enc (void *p, uint32_t x)
 Write host-endian 32-bit int to memory.
static void h64enc (void *p, uint64_t x)
 Write host-endian 64-bit int to memory.

Detailed Description

Endianess conversion, convert integers to bytes.


Define Documentation

#define htobe16 (   x)

Convert native 16-bit int to big-endian.

Referenced by be16dec(), and be16enc().

#define htobe32 (   x)

Convert native 32-bit int to big-endian.

Referenced by be32dec(), and be32enc().

#define htobe64 (   x)

Convert native 64-bit int to big-endian.

Referenced by be64dec(), and be64enc().

#define htole16 (   x)

Convert native 16-bit int to little-endian.

Referenced by le16dec(), and le16enc().

#define htole32 (   x)

Convert native 32-bit int to little-endian.

Referenced by le32dec(), and le32enc().

#define htole64 (   x)

Convert native 64-bit int to little-endian.

Referenced by le64dec(), and le64enc().

#define be16toh (   x)

Convert big-endian 16-bit int to host-endian.

#define be32toh (   x)

Convert big-endian 32-bit int to host-endian.

#define be64toh (   x)

Convert big-endian 64-bit int to host-endian.

#define le16toh (   x)

Convert little-endian 64-bit int to host-endian.

#define le32toh (   x)

Convert little-endian 64-bit int to host-endian.

#define le64toh (   x)

Convert little-endian 64-bit int to host-endian.


Function Documentation

static uint16_t bswap16 ( uint16_t  x) [inline, static]

Swap 16-bit int.

static uint32_t bswap32 ( uint32_t  x) [inline, static]

Swap 32-bit int.

Referenced by bswap64().

static uint64_t bswap64 ( uint64_t  x) [inline, static]

Swap 64-bit int.

References bswap32().

static uint16_t be16dec ( const void *  p) [inline, static]

Read big-endian 16-bit int from memory.

References htobe16.

static uint32_t be32dec ( const void *  p) [inline, static]

Read big-endian 32-bit int from memory.

References htobe32.

static uint64_t be64dec ( const void *  p) [inline, static]

Read big-endian 64-bit int from memory.

References htobe64.

static uint16_t le16dec ( const void *  p) [inline, static]

Read little-endian 16-bit int from memory.

References htole16.

static uint32_t le32dec ( const void *  p) [inline, static]

Read little-endian 32-bit int from memory.

References htole32.

static uint64_t le64dec ( const void *  p) [inline, static]

Read little-endian 64-bit int from memory.

References htole64.

static uint16_t h16dec ( const void *  p) [inline, static]

Read host-endian 16-bit int from memory.

static uint32_t h32dec ( const void *  p) [inline, static]

Read host-endian 32-bit int from memory.

static uint64_t h64dec ( const void *  p) [inline, static]

Read host-endian 64-bit int from memory.

static void be16enc ( void *  p,
uint16_t  x 
) [inline, static]

Write big-endian 16-bit int to memory.

References htobe16.

static void be32enc ( void *  p,
uint32_t  x 
) [inline, static]

Write big-endian 32-bit int to memory.

References htobe32.

static void be64enc ( void *  p,
uint64_t  x 
) [inline, static]

Write big-endian 64-bit int to memory.

References htobe64.

static void le16enc ( void *  p,
uint16_t  x 
) [inline, static]

Write little-endian 16-bit int to memory.

References htole16.

static void le32enc ( void *  p,
uint32_t  x 
) [inline, static]

Write little-endian 32-bit int to memory.

References htole32.

static void le64enc ( void *  p,
uint64_t  x 
) [inline, static]

Write little-endian 64-bit int to memory.

References htole64.

static void h16enc ( void *  p,
uint16_t  x 
) [inline, static]

Write host-endian 16-bit int to memory.

static void h32enc ( void *  p,
uint32_t  x 
) [inline, static]

Write host-endian 32-bit int to memory.

static void h64enc ( void *  p,
uint64_t  x 
) [inline, static]

Write host-endian 64-bit int to memory.