summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-05-28 02:40:05 +0200
committerGravatar Nikias Bassen2011-05-28 02:40:05 +0200
commitb9a1f74275de719eb19bdce86d765b306b072b69 (patch)
tree41f61e5c8787fdeaa9bc79ccbae8466f7d04d965 /src
parent4d4175a13703c066b771c52eb73231a5e35ba54e (diff)
downloadlibplist-b9a1f74275de719eb19bdce86d765b306b072b69.tar.gz
libplist-b9a1f74275de719eb19bdce86d765b306b072b69.tar.bz2
define be16toh, be32toh, be64toh if not available
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 77e6245..d03dc2b 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -133,6 +133,40 @@ static uint32_t uint24_from_be(union plist_uint_ptr buf)
return ret;
}
+#ifndef be16toh
+#if PLIST_BYTE_ORDER == PLIST_BIG_ENDIAN
+#define be16toh(x) (x)
+#else
+#define be16toh(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
+#endif
+#endif
+
+#ifndef be32toh
+#if PLIST_BYTE_ORDER == PLIST_BIG_ENDIAN
+#define be32toh(x) (x)
+#else
+#define be32toh(x) ((((x) & 0xFF000000) >> 24) \
+ | (((x) & 0x00FF0000) >> 8) \
+ | (((x) & 0x0000FF00) << 8) \
+ | (((x) & 0x000000FF) << 24))
+#endif
+#endif
+
+#ifndef be64toh
+#if PLIST_BYTE_ORDER == PLIST_BIG_ENDIAN
+#define be64toh(x) (x)
+#else
+#define be64toh(x) ((((x) & 0xFF00000000000000ull) >> 56) \
+ | (((x) & 0x00FF000000000000ull) >> 40) \
+ | (((x) & 0x0000FF0000000000ull) >> 24) \
+ | (((x) & 0x000000FF00000000ull) >> 8) \
+ | (((x) & 0x00000000FF000000ull) << 8) \
+ | (((x) & 0x0000000000FF0000ull) << 24) \
+ | (((x) & 0x000000000000FF00ull) << 40) \
+ | (((x) & 0x00000000000000FFull) << 56))
+#endif
+#endif
+
#define UINT_TO_HOST(x, n) \
({ \
union plist_uint_ptr __up; \