summaryrefslogtreecommitdiff
path: root/lib/portability.h
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-02-13 16:41:51 -0500
committerRob Landley <rob@landley.net>2007-02-13 16:41:51 -0500
commit2aa494dcfe701e080e62f3d2a36af84b2ee16837 (patch)
tree9f6a33a599833e6211f3891bb39fd7c784784ce5 /lib/portability.h
parent4f5a671bf49bcce98be1a0be847cf4f5eaeacd2a (diff)
downloadtoybox-2aa494dcfe701e080e62f3d2a36af84b2ee16837.tar.gz
toybox-2aa494dcfe701e080e62f3d2a36af84b2ee16837.tar.bz2
toybox-2aa494dcfe701e080e62f3d2a36af84b2ee16837.zip
MacOS X has a defective sed with no -r.
Diffstat (limited to 'lib/portability.h')
-rw-r--r--lib/portability.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/portability.h b/lib/portability.h
index 9f3f1b7..6ed1dc4 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -1,13 +1,30 @@
-
// Humor glibc to get dprintf, then #define it to something more portable.
#define _GNU_SOURCE
#include <stdio.h>
#define fdprintf(...) dprintf(__VA_ARGS__)
+
+#ifndef __APPLE__
+#include <byteswap.h>
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
#define IS_BIG_ENDIAN 1
+#else
+#define IS_BIG_ENDIAN 0
+#endif
+
+#else
+
+#ifdef __BIG_ENDIAN__
+#define IS_BIG_ENDIAN 1
+#else
+#define IS_BIG_ENDIAN 0
+#endif
+
+#endif
+
+#if IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 0
#define SWAP_BE16(x) (x)
#define SWAP_BE32(x) (x)
@@ -17,7 +34,6 @@
#define SWAP_LE64(x) bswap_64(x)
#else
#define IS_LITTLE_ENDIAN 1
-#define IS_BIG_ENDIAN 0
#define SWAP_BE16(x) bswap_16(x)
#define SWAP_BE32(x) bswap_32(x)
#define SWAP_BE64(x) bswap_64(x)