OSDN Git Service

shared: Add get_be16()
authorClaudio Takahasi <claudio.takahasi@openbossa.org>
Thu, 20 Mar 2014 14:42:30 +0000 (11:42 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 21 Mar 2014 08:36:08 +0000 (10:36 +0200)
Add helper to avoid possible unaligned memory access when handling
uint16 value using big-endian representation.

src/shared/util.h

index 29f6f6b..e315f84 100644 (file)
@@ -106,6 +106,11 @@ static inline uint16_t get_le16(const void *ptr)
        return le16_to_cpu(get_unaligned((const uint16_t *) ptr));
 }
 
+static inline uint16_t get_be16(const void *ptr)
+{
+       return be16_to_cpu(get_unaligned((const uint16_t *) ptr));
+}
+
 static inline uint32_t get_le32(const void *ptr)
 {
        return le32_to_cpu(get_unaligned((const uint32_t *) ptr));