mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH v2 2/5] byteorder: add sanity check
Date: Thu, 28 Jun 2012 22:32:31 +0400	[thread overview]
Message-ID: <1340908354-17895-3-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1340908354-17895-1-git-send-email-antonynpavlov@gmail.com>

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.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 include/common.h |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/common.h b/include/common.h
index 9745aeb..ece3d13 100644
--- a/include/common.h
+++ b/include/common.h
@@ -241,4 +241,22 @@ static inline void barebox_banner(void) {}
 		(__x < 0) ? -__x : __x;         \
 	})
 
+/*
+ * 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
+
 #endif	/* __COMMON_H_ */
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-06-28 18:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
2012-06-29  7:25   ` Sascha Hauer
2012-06-29  7:36     ` Sascha Hauer
2012-06-29  8:48     ` Antony Pavlov
2012-06-29  9:13       ` Sascha Hauer
2012-06-28 18:32 ` Antony Pavlov [this message]
2012-06-28 18:32 ` [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov
2012-06-29  7:57   ` Sascha Hauer
2012-06-28 18:32 ` [PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340908354-17895-3-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox