diff --git a/sys/include/unaligned.h b/sys/include/unaligned.h index ced46ac328..1ea3bce83f 100644 --- a/sys/include/unaligned.h +++ b/sys/include/unaligned.h @@ -53,6 +53,11 @@ typedef struct __attribute__((packed)) { uint32_t val; /**< value */ } uint32_una_t; +/** @brief Unaligned access helper struct (uint64_t version) */ +typedef struct __attribute__((packed)) { + uint64_t val; /**< value */ +} uint64_una_t; + /** * @brief Get uint16_t from possibly unaligned pointer * @@ -79,6 +84,19 @@ static inline uint32_t unaligned_get_u32(const void *ptr) return tmp->val; } +/** + * @brief Get uint64_t from possibly unaligned pointer + * + * @param[in] ptr pointer to read from + * + * @returns value read from @p ptr + */ +static inline uint64_t unaligned_get_u64(const void *ptr) +{ + const uint64_una_t *tmp = (const uint64_una_t *)ptr; + return tmp->val; +} + #ifdef __cplusplus } #endif