summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2019-05-27 11:57:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-05-28 10:36:09 +0200
commit70e4e1e4f54ff8e4040b137a2b4d0f48baa74e0c (patch)
treef2f5a23edf72c6ec09046da48c938cd937beecec /scripts
parent536e8ef97682083eb84efccbf5a3b0188eb466c5 (diff)
downloadbarebox-70e4e1e4f54ff8e4040b137a2b4d0f48baa74e0c.tar.gz
barebox-70e4e1e4f54ff8e4040b137a2b4d0f48baa74e0c.tar.xz
scripts: compiler.h: support BSDs as well
The BSDs have their endianness changing functions in <sys/endian.h> and define both _BYTE_ORDER as well as BYTE_ORDER (if strict POSIX conformance isn't requested). Extend the header to compile, so it supports these platforms as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/compiler.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/compiler.h b/scripts/compiler.h
index 01b0de44f1..0ad25f9e8d 100644
--- a/scripts/compiler.h
+++ b/scripts/compiler.h
@@ -56,16 +56,22 @@
# else /* non apple __MACH__ */
# include <machine/endian.h>
# endif /* __APPLE__ */
-# define __BYTE_ORDER BYTE_ORDER
-# define __LITTLE_ENDIAN LITTLE_ENDIAN
-# define __BIG_ENDIAN BIG_ENDIAN
typedef unsigned long ulong;
typedef unsigned int uint;
+#elif defined(__OpenBSD__) || defined(__FreeBSD__) || \
+ defined(__NetBSD__) || defined(__DragonFly__)
+# include <sys/endian.h>
#else /* assume Linux */
# include <endian.h>
# include <byteswap.h>
#endif
+#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
+# define __BYTE_ORDER BYTE_ORDER
+# define __BIG_ENDIAN BIG_ENDIAN
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+
typedef uint8_t __u8;
typedef uint16_t __u16;
typedef uint32_t __u32;