Skip to content

Commit 78825ed

Browse files
jukkarioannisg
authored andcommitted
sys: byteorder: Add support for sys_put_be64()
There is sys_get_be64() but nothing for storing a 64-bit big-endian version. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent bbac6e5 commit 78825ed

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/sys/byteorder.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ static inline void sys_put_be32(u32_t val, u8_t dst[4])
154154
sys_put_be16(val, &dst[2]);
155155
}
156156

157+
/**
158+
* @brief Put a 64-bit integer as big-endian to arbitrary location.
159+
*
160+
* Put a 64-bit integer, originally in host endianness, to a
161+
* potentially unaligned memory location in big-endian format.
162+
*
163+
* @param val 64-bit integer in host endianness.
164+
* @param dst Destination memory address to store the result.
165+
*/
166+
static inline void sys_put_be64(u64_t val, u8_t dst[8])
167+
{
168+
sys_put_be32(val >> 32, dst);
169+
sys_put_be32(val, &dst[4]);
170+
}
171+
157172
/**
158173
* @brief Put a 16-bit integer as little-endian to arbitrary location.
159174
*

0 commit comments

Comments
 (0)