sys: byteorder: Add support for sys_get_be64()
There is sys_get_le64() already but nothing for 64-bit big-endian version. Fixes #18258 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
3590c80aaf
commit
0a6a10d0c4
1 changed files with 15 additions and 0 deletions
|
@ -229,6 +229,21 @@ static inline u32_t sys_get_be32(const u8_t src[4])
|
|||
return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 64-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 64-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 64-bit integer to get.
|
||||
*
|
||||
* @return 64-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_be64(const u8_t src[8])
|
||||
{
|
||||
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 16-bit integer stored in little-endian format.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue