Sometimes it is useful to access values which are not correctly aligned. To avoid slow copying to aligned buffers, we define several optimized read/write functions for accessing such integer values.
static inline uint get_u16_be(const void *p);
Read 16-bit integer value from an unaligned sequence of 2 bytes (big-endian version).
static inline u32 get_u32_be(const void *p);
Read 32-bit integer value from an unaligned sequence of 4 bytes (big-endian version).
static inline u64 get_u64_be(const void *p);
Read 64-bit integer value from an unaligned sequence of 8 bytes (big-endian version).
static inline void put_u16_be(void *p, uint x);
Write 16-bit integer value to an unaligned sequence of 2 bytes (big-endian version).
static inline void put_u32_be(void *p, u32 x);
Write 32-bit integer value to an unaligned sequence of 4 bytes (big-endian version).
static inline void put_u64_be(void *p, u64 x);
Write 64-bit integer value to an unaligned sequence of 8 bytes (big-endian version).
static inline u64 get_u40_be(const void *p);
Read 40-bit integer value from an unaligned sequence of 5 bytes (big-endian version).
static inline uint get_u16_le(const void *p);
Read 16-bit integer value from an unaligned sequence of 2 bytes (little-endian version).
static inline u32 get_u32_le(const void *p);
Read 32-bit integer value from an unaligned sequence of 4 bytes (little-endian version).
static inline u64 get_u64_le(const void *p);
Read 64-bit integer value from an unaligned sequence of 8 bytes (little-endian version).
static inline void put_u16_le(void *p, uint x);
Write 16-bit integer value to an unaligned sequence of 2 bytes (little-endian version).
static inline void put_u32_le(void *p, u32 x);
Write 32-bit integer value to an unaligned sequence of 4 bytes (little-endian version).
static inline void put_u64_le(void *p, u64 x);
Write 64-bit integer value to an unaligned sequence of 8 bytes (little-endian version).
static inline u64 get_u40_le(const void *p);
Read 40-bit integer value from an unaligned sequence of 5 bytes (little-endian version).
static inline uint get_u16(const void *p);
Read 16-bit integer value from an unaligned sequence of 2 bytes (native byte-order).
static inline u32 get_u32(const void *p);
Read 32-bit integer value from an unaligned sequence of 4 bytes (native byte-order).
static inline u64 get_u64(const void *p);
Read 64-bit integer value from an unaligned sequence of 8 bytes (native byte-order).
static inline u64 get_u40(const void *p);
Read 40-bit integer value from an unaligned sequence of 5 bytes (native byte-order).
static inline void put_u16(void *p, uint x);
Write 16-bit integer value to an unaligned sequence of 2 bytes (native byte-order).
static inline void put_u32(void *p, u32 x);
Write 32-bit integer value to an unaligned sequence of 4 bytes (native byte-order).
static inline void put_u64(void *p, u64 x);
Write 64-bit integer value to an unaligned sequence of 8 bytes (native byte-order).
static inline void put_u40(void *p, u64 x);
Write 40-bit integer value to an unaligned sequence of 5 bytes (native byte-order).
static inline uint get_u8(const void *p);
Read 8-bit integer value.
static inline void put_u8(void *p, uint x);
Write 8-bit integer value.