EtcPal
HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
Platform- and endianness-independent buffer packing and unpacking.
For 16- and 32-bit integer packing and unpacking:
For 64-bit integer packing and unpacking:
This module defines macros for packing and unpacking integer types to/from a byte buffer. They are architected in such a way that the endianness of the integer in the buffer is always known, regardless of the endianness of your platform.
For example:
Functions | |
int16_t | etcpal_unpack_i16b (const uint8_t *buf) |
Unpack an int16_t from a known big-endian buffer. More... | |
void | etcpal_pack_i16b (uint8_t *buf, int16_t val) |
Pack an int16_t to a known big-endian buffer. More... | |
int16_t | etcpal_unpack_i16l (const uint8_t *buf) |
Unpack an int16_t from a known little-endian buffer. More... | |
void | etcpal_pack_i16l (uint8_t *buf, int16_t val) |
Pack an int16_t to a known little-endian buffer. More... | |
uint16_t | etcpal_unpack_u16b (const uint8_t *buf) |
Unpack a uint16_t from a known big-endian buffer. More... | |
void | etcpal_pack_u16b (uint8_t *buf, uint16_t val) |
Pack a uint16_t to a known big-endian buffer. More... | |
uint16_t | etcpal_unpack_u16l (const uint8_t *buf) |
Unpack a uint16_t from a known little-endian buffer. More... | |
void | etcpal_pack_u16l (uint8_t *buf, uint16_t val) |
Pack a uint16_t to a known little-endian buffer. More... | |
int32_t | etcpal_unpack_i32b (const uint8_t *buf) |
Unpack an int32_t from a known big-endian buffer. More... | |
void | etcpal_pack_i32b (uint8_t *buf, int32_t val) |
Pack an int32_t to a known big-endian buffer. More... | |
int32_t | etcpal_unpack_i32l (const uint8_t *buf) |
Unpack an int32_t from a known little-endian buffer. More... | |
void | etcpal_pack_i32l (uint8_t *buf, int32_t val) |
Pack an int32_t to a known little-endian buffer. More... | |
uint32_t | etcpal_unpack_u32b (const uint8_t *buf) |
Unpack a uint32_t from a known big-endian buffer. More... | |
void | etcpal_pack_u32b (uint8_t *buf, uint32_t val) |
Pack a uint32_t to a known big-endian buffer. More... | |
uint32_t | etcpal_unpack_u32l (const uint8_t *buf) |
Unpack a uint32_t from a known little-endian buffer. More... | |
void | etcpal_pack_u32l (uint8_t *buf, uint32_t val) |
Pack a uint32_t to a known little-endian buffer. More... | |
int64_t | etcpal_unpack_i64b (const uint8_t *buf) |
Unpack an int64_t from a known big-endian buffer. More... | |
void | etcpal_pack_i64b (uint8_t *buf, int64_t val) |
Pack an int64_t to a known big-endian buffer. More... | |
int64_t | etcpal_unpack_i64l (const uint8_t *buf) |
Unpack an int64_t from a known little-endian buffer. More... | |
void | etcpal_pack_i64l (uint8_t *buf, int64_t val) |
Pack an int64_t to a known little-endian buffer. More... | |
uint64_t | etcpal_unpack_u64b (const uint8_t *buf) |
Unpack a uint64_t from a known big-endian buffer. More... | |
void | etcpal_pack_u64b (uint8_t *buf, uint64_t val) |
Pack a uint64_t to a known big-endian buffer. More... | |
uint64_t | etcpal_unpack_u64l (const uint8_t *buf) |
Unpack a uint64_t from a known little-endian buffer. More... | |
void | etcpal_pack_u64l (uint8_t *buf, uint64_t val) |
Pack a uint64_t to a known little-endian buffer. More... | |
void etcpal_pack_i16b | ( | uint8_t * | buf, |
int16_t | val | ||
) |
Pack an int16_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 2 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_i16l | ( | uint8_t * | buf, |
int16_t | val | ||
) |
Pack an int16_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 2 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_i32b | ( | uint8_t * | buf, |
int32_t | val | ||
) |
Pack an int32_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 4 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_i32l | ( | uint8_t * | buf, |
int32_t | val | ||
) |
Pack an int32_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 4 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_i64b | ( | uint8_t * | buf, |
int64_t | val | ||
) |
Pack an int64_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 8 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_i64l | ( | uint8_t * | buf, |
int64_t | val | ||
) |
Pack an int64_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 8 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u16b | ( | uint8_t * | buf, |
uint16_t | val | ||
) |
Pack a uint16_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 2 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u16l | ( | uint8_t * | buf, |
uint16_t | val | ||
) |
Pack a uint16_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 2 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u32b | ( | uint8_t * | buf, |
uint32_t | val | ||
) |
Pack a uint32_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 4 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u32l | ( | uint8_t * | buf, |
uint32_t | val | ||
) |
Pack a uint32_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 4 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u64b | ( | uint8_t * | buf, |
uint64_t | val | ||
) |
Pack a uint64_t to a known big-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 8 bytes in size. |
val | Value to pack into the buffer. |
void etcpal_pack_u64l | ( | uint8_t * | buf, |
uint64_t | val | ||
) |
Pack a uint64_t to a known little-endian buffer.
buf | Pointer to the buffer into which to pack a value; must be at least 8 bytes in size. |
val | Value to pack into the buffer. |
int16_t etcpal_unpack_i16b | ( | const uint8_t * | buf | ) |
Unpack an int16_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 2 bytes in size. |
int16_t etcpal_unpack_i16l | ( | const uint8_t * | buf | ) |
Unpack an int16_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 2 bytes in size. |
int32_t etcpal_unpack_i32b | ( | const uint8_t * | buf | ) |
Unpack an int32_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 4 bytes in size. |
int32_t etcpal_unpack_i32l | ( | const uint8_t * | buf | ) |
Unpack an int32_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 4 bytes in size. |
int64_t etcpal_unpack_i64b | ( | const uint8_t * | buf | ) |
Unpack an int64_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 8 bytes in size. |
int64_t etcpal_unpack_i64l | ( | const uint8_t * | buf | ) |
Unpack an int64_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 8 bytes in size. |
uint16_t etcpal_unpack_u16b | ( | const uint8_t * | buf | ) |
Unpack a uint16_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 2 bytes in size. |
uint16_t etcpal_unpack_u16l | ( | const uint8_t * | buf | ) |
Unpack a uint16_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 2 bytes in size. |
uint32_t etcpal_unpack_u32b | ( | const uint8_t * | buf | ) |
Unpack a uint32_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 4 bytes in size. |
uint32_t etcpal_unpack_u32l | ( | const uint8_t * | buf | ) |
Unpack a uint32_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 4 bytes in size. |
uint64_t etcpal_unpack_u64b | ( | const uint8_t * | buf | ) |
Unpack a uint64_t from a known big-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 8 bytes in size. |
uint64_t etcpal_unpack_u64l | ( | const uint8_t * | buf | ) |
Unpack a uint64_t from a known little-endian buffer.
buf | Pointer to the buffer from which to unpack a value; must be at least 8 bytes in size. |