about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-05-06 13:40:19 -0400
committerRich Felker <dalias@aerifal.cx>2012-05-06 13:40:19 -0400
commita3b20f67b35e26813d02e08043db2a5d9263f255 (patch)
treed398555d5bec997dbe13314664efe508565c59e9
parenta45de0cb94b58f1b5ea4af1ca3531c56dc02c0a2 (diff)
downloadmusl-a3b20f67b35e26813d02e08043db2a5d9263f255.tar.gz
musl-a3b20f67b35e26813d02e08043db2a5d9263f255.tar.xz
musl-a3b20f67b35e26813d02e08043db2a5d9263f255.zip
take byte order from gcc if gcc has defined it
this only works with gcc 4.6 and later, but it allows us to support
non-default endianness on archs like arm, mips, ppc, etc. that can do
both without having separate header sets for both variants, and it
saves one #include even on fixed-endianness archs like x86.
-rw-r--r--include/endian.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/endian.h b/include/endian.h
index 9652c30b..41ca1711 100644
--- a/include/endian.h
+++ b/include/endian.h
@@ -5,7 +5,11 @@
 #define __BIG_ENDIAN 4321
 #define __PDP_ENDIAN 3412
 
+#if defined(__GNUC__) && defined(__BYTE_ORDER__)
+#define __BYTE_ORDER __BYTE_ORDER__
+#else
 #include <bits/endian.h>
+#endif
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)