OSDN Git Service

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

src/shared/util.h

index 251ea2a..9e4d0c0 100644 (file)
@@ -126,6 +126,11 @@ static inline uint64_t get_le64(const void *ptr)
        return le64_to_cpu(get_unaligned((const uint64_t *) ptr));
 }
 
+static inline uint64_t get_be64(const void *ptr)
+{
+       return be64_to_cpu(get_unaligned((const uint64_t *) ptr));
+}
+
 static inline void put_le16(uint16_t val, void *dst)
 {
        put_unaligned(cpu_to_le16(val), (uint16_t *) dst);