summaryrefslogtreecommitdiffstats
path: root/include/envfs.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-06-28 09:56:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-06-28 13:49:16 +0200
commit51885a7d7321c3e6395c36bc4fe8dde7e78cf562 (patch)
treec656f1c1e2571181aed4870aaa2e63861120d783 /include/envfs.h
parenta6e358b2f5b219fda18a7bc9348cb969043c19d5 (diff)
downloadbarebox-51885a7d7321c3e6395c36bc4fe8dde7e78cf562.tar.gz
barebox-51885a7d7321c3e6395c36bc4fe8dde7e78cf562.tar.xz
Change byte order detection mechanism to kernel style
The Linux Kernel defines only one of __LITTLE_ENDIAN and __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then be tested with #if __BYTE_ORDER == __xx_ENDIAN. As we tend to use a lot of Kernel code in barebox we switch to use the kernel way of determing the byte order. As this always causes a lot of confusion add a check to include/common.h to make sure only one of __LITTLE_ENDIAN and __BIG_ENDIAN is defined. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/envfs.h')
-rw-r--r--include/envfs.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/envfs.h b/include/envfs.h
index 67b890222c..ba976d6d13 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -34,11 +34,25 @@ struct envfs_super {
uint32_t sb_crc; /* crc for the superblock */
};
-#ifndef __BYTE_ORDER
-#error "No byte order defined in __BYTE_ORDER"
+#ifdef __BAREBOX__
+# ifdef __LITTLE_ENDIAN
+# define ENVFS_ORDER_LITTLE
+# elif defined __BIG_ENDIAN
+# define ENVFS_ORDER_BIG
+# else
+# error "could not determine byte order"
+# endif
+#else
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ENVFS_ORDER_LITTLE
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# define ENVFS_ORDER_BIG
+# else
+# error "could not determine byte order"
+# endif
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef ENVFS_ORDER_LITTLE
#define ENVFS_16(x) (x)
#define ENVFS_24(x) (x)
#define ENVFS_32(x) (x)
@@ -46,7 +60,7 @@ struct envfs_super {
#define ENVFS_GET_OFFSET(x) ((x)->offset)
#define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y))
#define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif defined ENVFS_ORDER_BIG
#ifdef __KERNEL__
#define ENVFS_16(x) swab16(x)
#define ENVFS_24(x) ((swab32(x)) >> 8)