From be50f325cf13de4360f42bb23eafda109a1e1a20 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 20 Mar 2014 11:42:31 -0300 Subject: [PATCH] shared: Add get_be32() Add helper to avoid possible unaligned memory access when handling uint32 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 e315f846f..251ea2a09 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -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)); -- 2.11.0