OSDN Git Service

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

src/shared/util.h

index e315f84..251ea2a 100644 (file)
@@ -116,6 +116,11 @@ static inline uint32_t get_le32(const void *ptr)
        return le32_to_cpu(get_unaligned((const uint32_t *) ptr));
 }
 
+static inline uint32_t get_be32(const void *ptr)
+{
+       return be32_to_cpu(get_unaligned((const uint32_t *) ptr));
+}
+
 static inline uint64_t get_le64(const void *ptr)
 {
        return le64_to_cpu(get_unaligned((const uint64_t *) ptr));