e6679fe
From 4be5f3a7a245506af5e82fa47911c96c24c34f60 Mon Sep 17 00:00:00 2001
a1e5088
From: Peter Lemenkov <lemenkov@gmail.com>
a1e5088
Date: Sun, 26 Sep 2010 18:25:31 +0400
f4ee62f
Subject: [PATCH 6/9] Use endiannes determined at the configure stage
a1e5088
a1e5088
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
a1e5088
---
f4ee62f
 hwaccess.h |   60 ++----------------------------------------------------------
f4ee62f
 1 file changed, 2 insertions(+), 58 deletions(-)
a1e5088
a1e5088
diff --git a/hwaccess.h b/hwaccess.h
f4ee62f
index be3af34..7d9b108 100644
a1e5088
--- a/hwaccess.h
a1e5088
+++ b/hwaccess.h
f4ee62f
@@ -41,58 +41,6 @@
a1e5088
 #undef index
a1e5088
 #endif
a1e5088
 
a1e5088
-#if defined (__i386__) || defined (__x86_64__)
a1e5088
-
a1e5088
-/* All x86 is little-endian. */
a1e5088
-#define __FLASHROM_LITTLE_ENDIAN__ 1
a1e5088
-
a1e5088
-#elif defined (__mips) || defined (__mips__) || defined (_mips) || defined (mips)
a1e5088
-
a1e5088
-/* MIPS can be either endian. */
a1e5088
-#if defined (__MIPSEL) || defined (__MIPSEL__) || defined (_MIPSEL) || defined (MIPSEL)
a1e5088
-#define __FLASHROM_LITTLE_ENDIAN__ 1
a1e5088
-#elif defined (__MIPSEB) || defined (__MIPSEB__) || defined (_MIPSEB) || defined (MIPSEB)
a1e5088
-#define __FLASHROM_BIG_ENDIAN__ 1
a1e5088
-#endif
a1e5088
-
a1e5088
-#elif defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__)
a1e5088
-
a1e5088
-/* PowerPC can be either endian. */
a1e5088
-#if defined (_BIG_ENDIAN) || defined (__BIG_ENDIAN__)
a1e5088
-#define __FLASHROM_BIG_ENDIAN__ 1
a1e5088
-/* Error checking in case some weird header has #defines for LE as well. */
a1e5088
-#if defined (_LITTLE_ENDIAN) || defined (__LITTLE_ENDIAN__)
a1e5088
-#error Conflicting endianness #define
a1e5088
-#endif
a1e5088
-#else
a1e5088
-#error Little-endian PowerPC #defines are unknown
a1e5088
-#endif
a1e5088
-
f4ee62f
-#elif defined (__arm__)
f4ee62f
-#if defined (__ARMEL__)
f4ee62f
-#define __FLASHROM_LITTLE_ENDIAN__ 1
f4ee62f
-#else
f4ee62f
-#error Big-endian ARM #defines are unknown
f4ee62f
-#endif
f4ee62f
-
a1e5088
-#endif
a1e5088
-
a1e5088
-#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__)
a1e5088
-/* Nonstandard libc-specific macros for determining endianness. */
a1e5088
-#if defined(__GLIBC__)
a1e5088
-#include <endian.h>
a1e5088
-#if BYTE_ORDER == LITTLE_ENDIAN
a1e5088
-#define __FLASHROM_LITTLE_ENDIAN__ 1
a1e5088
-#elif BYTE_ORDER == BIG_ENDIAN
a1e5088
-#define __FLASHROM_BIG_ENDIAN__ 1
a1e5088
-#endif
a1e5088
-#endif
a1e5088
-#endif
a1e5088
-
a1e5088
-#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__)
a1e5088
-#error Unable to determine endianness. Please add support for your arch or libc.
a1e5088
-#endif
a1e5088
-
a1e5088
 #define ___constant_swab8(x) ((uint8_t) (				\
a1e5088
 	(((uint8_t)(x) & (uint8_t)0xffU))))
a1e5088
 
f4ee62f
@@ -134,7 +82,7 @@ cpu_to_le(64)
a1e5088
 #define cpu_to_be32
a1e5088
 #define cpu_to_be64
a1e5088
 
a1e5088
-#elif defined (__FLASHROM_LITTLE_ENDIAN__)
a1e5088
+#else /* defined (__FLASHROM_BIG_ENDIAN__) */
a1e5088
 
a1e5088
 #define cpu_to_be(bits)							\
a1e5088
 static inline uint##bits##_t cpu_to_be##bits(uint##bits##_t val)	\
f4ee62f
@@ -152,11 +100,7 @@ cpu_to_be(64)
a1e5088
 #define cpu_to_le32
a1e5088
 #define cpu_to_le64
a1e5088
 
a1e5088
-#else
a1e5088
-
a1e5088
-#error Could not determine endianness.
a1e5088
-
a1e5088
-#endif
a1e5088
+#endif /* defined (__FLASHROM_BIG_ENDIAN__) */
a1e5088
 
a1e5088
 #define be_to_cpu8 cpu_to_be8
a1e5088
 #define be_to_cpu16 cpu_to_be16
a1e5088
-- 
e6679fe
1.7.10.1
a1e5088