summaryrefslogtreecommitdiff
path: root/openwrt/tools/include/endian.h
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-09-27 17:03:36 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-09-27 17:03:36 +0000
commit49abfada1f475fe670e22c05e6efdfa46fbd0804 (patch)
tree329be23efac79bc10b4202f3375dc791ca1bfa17 /openwrt/tools/include/endian.h
parentbf28127b91700a7a886f9d3411be151864eb6057 (diff)
downloadmtk-20170518-49abfada1f475fe670e22c05e6efdfa46fbd0804.zip
mtk-20170518-49abfada1f475fe670e22c05e6efdfa46fbd0804.tar.gz
mtk-20170518-49abfada1f475fe670e22c05e6efdfa46fbd0804.tar.bz2
add portability fixes for toolchain/tools (full tools/toolchain build works on osx now)
SVN-Revision: 4867
Diffstat (limited to 'openwrt/tools/include/endian.h')
-rw-r--r--openwrt/tools/include/endian.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/openwrt/tools/include/endian.h b/openwrt/tools/include/endian.h
new file mode 100644
index 0000000..4ea34cd
--- /dev/null
+++ b/openwrt/tools/include/endian.h
@@ -0,0 +1,29 @@
+#ifndef __endian_compat_h
+#define __endian_compat_h
+
+#if defined(__linux__)
+#include_next <endian.h>
+#elif defined(__APPLE__)
+#include <machine/endian.h>
+#include <machine/byte_order.h>
+#define bswap_16(x) NXSwapShort(x)
+#define bswap_32(x) NXSwapInt(x)
+#define bswap_64(x) NXSwapLongLong(x)
+#else
+#include <machine/endian.h>
+#define bswap_16(x) swap16(x)
+#define bswap_32(x) swap32(x)
+#define bswap_64(x) swap64(x)
+#endif
+
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER BYTE_ORDER
+#endif
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#endif
+
+#endif