From c2aef3ba48c99d8a4c0555459fcbb3f9ebc05885 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 10 Jan 2014 13:16:23 -0800 Subject: [PATCH] shared: Fix the endian helper macros to work on big endian systems --- src/shared/util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/shared/util.h b/src/shared/util.h index ac07fb74f..083d847f4 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -23,11 +23,21 @@ #include #include +#include +#if __BYTE_ORDER == __LITTLE_ENDIAN #define le16_to_cpu(val) (val) #define le32_to_cpu(val) (val) #define cpu_to_le16(val) (val) #define cpu_to_le32(val) (val) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define le16_to_cpu(val) bswap_16(val) +#define le32_to_cpu(val) bswap_32(val) +#define cpu_to_le16(val) bswap_16(val) +#define cpu_to_le32(val) bswap_32(val) +#else +#error "Unknown byte order" +#endif #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) #define UINT_TO_PTR(u) ((void *) ((uintptr_t) (u))) -- 2.47.3