|
| size_t | pc_wr16le (uint8_t *p, uint16_t v) |
| | Write v little-endian at p.
|
| |
| size_t | pc_wr32le (uint8_t *p, uint32_t v) |
| | Write v little-endian at p.
|
| |
| size_t | pc_wr64le (uint8_t *p, uint64_t v) |
| | Write v little-endian at p.
|
| |
| uint16_t | pc_rd16le (const uint8_t *p) |
| | Read a little-endian u16 at p.
|
| |
| uint32_t | pc_rd32le (const uint8_t *p) |
| | Read a little-endian u32 at p.
|
| |
| uint64_t | pc_rd64le (const uint8_t *p) |
| | Read a little-endian u64 at p.
|
| |
| size_t | pc_wr16be (uint8_t *p, uint16_t v) |
| | Write v big-endian at p.
|
| |
| size_t | pc_wr32be (uint8_t *p, uint32_t v) |
| | Write v big-endian at p.
|
| |
| size_t | pc_wr64be (uint8_t *p, uint64_t v) |
| | Write v big-endian at p.
|
| |
| uint16_t | pc_rd16be (const uint8_t *p) |
| | Read a big-endian u16 at p.
|
| |
| uint32_t | pc_rd32be (const uint8_t *p) |
| | Read a big-endian u32 at p.
|
| |
| uint64_t | pc_rd64be (const uint8_t *p) |
| | Read a big-endian u64 at p.
|
| |
Fixed-width integer serializers into a raw uint8_t* buffer - one source of truth.
Every binary codec (ADS, AMQP, C37.118, NetFlow, WAL, SHA-1/256, NTLMSSP/SMB2, ...) had its own byte-for-byte copy of these little-/big-endian pack/unpack helpers under a different local name (put16le / put16 / wr16 / store_be32 / put_u32 ...). They now live here once.
Writers return the number of bytes written (2/4/8) so a caller can advance an offset; a caller that only needs the side effect simply ignores the return. Readers assume p has at least the width in range - callers bounds-check the buffer, as the hand-rolled copies did.
Header-only and pure (only <stdint.h> / <stddef.h>) so it is host-testable and identical on device + host, and carries zero link cost when unused.
- Author
- Douglas Quigg (dstroy0)
- Date
- 2026
Definition in file endian.h.