From ce5c106efc3c23c416cddc1842f57bcff12eefad Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 20 Mar 2014 11:42:33 -0300 Subject: [PATCH] shared: Add put_be16() Add helper to avoid possible unaligned memory access when handling uint16 value using big-endian representation. --- src/shared/util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shared/util.h b/src/shared/util.h index 9e4d0c0f5..0d0b45ffb 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -136,6 +136,11 @@ static inline void put_le16(uint16_t val, void *dst) put_unaligned(cpu_to_le16(val), (uint16_t *) dst); } +static inline void put_be16(uint16_t val, const void *ptr) +{ + put_unaligned(cpu_to_be16(val), (uint16_t *) ptr); +} + static inline void put_le32(uint32_t val, void *dst) { put_unaligned(cpu_to_le32(val), (uint32_t *) dst); -- 2.11.0