mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/unaligned: Add 64 bit version
Add helper function to access `uint64_t` values with possibly unaligned pointers.
This commit is contained in:
parent
f64511ddb5
commit
030e0af985
@ -53,6 +53,11 @@ typedef struct __attribute__((packed)) {
|
|||||||
uint32_t val; /**< value */
|
uint32_t val; /**< value */
|
||||||
} uint32_una_t;
|
} 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
|
* @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;
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user