Provides functions for safe unaligned memory accesses. More...
Provides functions for safe unaligned memory accesses.
This header provides functions to read values from pointers that are not necessarily aligned to the type's alignment requirements.
uint16_t *foo = 0x123; printf("%u\n", *foo);
... might cause an unaligned access, if
uint16_t is usually aligned at 2-byte-boundaries, as foo has an odd address.
The current implementation casts a pointer to a packed struct, which forces the compiler to deal with possibly unalignedness. Idea taken from linux kernel sources.
|Unaligned but safe memory access functions. |
|Unaligned access helper struct (uint16_t version) More...|
|static uint16_t||unaligned_get_u16 (const void *ptr)|
|Get uint16_t from possibly unaligned pointer. More...|