[PATCH 04/12] include: common.h: move out endianness macro sanity check
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Oct 14 04:50:32 PDT 2024
This sanity check was added into common.h, so it's part of every build.
As we intend to move out everything that's not an include out of
common.h, let's move it somewhere, where it's still included in every
build, but isn't evaluated repeatedly all the time.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/common.h | 18 ------------------
lib/hexdump.c | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/include/common.h b/include/common.h
index d8e55114ce23..bab03a0444f7 100644
--- a/include/common.h
+++ b/include/common.h
@@ -23,24 +23,6 @@
#include <linux/printk.h>
#include <barebox-info.h>
-/*
- * sanity check. 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 use the kernel way of
- * determing the byte order. Make sure here that architecture code properly
- * defines it.
- */
-#include <asm/byteorder.h>
-#if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
-#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
-#endif
-#if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN
-#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
-#endif
-
/*
* Function Prototypes
*/
diff --git a/lib/hexdump.c b/lib/hexdump.c
index ae078536e3f0..940c4eec64e9 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -11,6 +11,26 @@
#include <linux/printk.h>
#include <asm/unaligned.h>
#include <pbl.h>
+#include <asm/byteorder.h>
+
+/*
+ * sanity check. 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 use the kernel way of
+ * determing the byte order. Make sure here that architecture code properly
+ * defines it.
+ * An additional benefit of placing this here is that this file is always built.
+ */
+#if defined __LITTLE_ENDIAN && defined __BIG_ENDIAN
+#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
+#endif
+#if !defined __LITTLE_ENDIAN && !defined __BIG_ENDIAN
+#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
+#endif
+
const char hex_asc[] = "0123456789abcdef";
EXPORT_SYMBOL(hex_asc);
--
2.39.5
More information about the barebox
mailing list