summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-03 17:54:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-03 18:00:10 +0200
commit64257e6eae4e5e73052c8249316df08b91a2445a (patch)
treeca78b5c8397b06459104e32658a3fa5899d58899 /src
parent639ea07d775056f1bcbc5a8df1a9d7a68eab4d33 (diff)
downloadfastd-64257e6eae4e5e73052c8249316df08b91a2445a.tar
fastd-64257e6eae4e5e73052c8249316df08b91a2445a.zip
Fix UHASH build on MacOS X
Diffstat (limited to 'src')
-rw-r--r--src/util.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/util.h b/src/util.h
index 3acc42f..db4457d 100644
--- a/src/util.h
+++ b/src/util.h
@@ -105,12 +105,28 @@ static inline size_t min_size_t(size_t a, size_t b) {
}
-#ifndef HAVE_LINUX_ENDIAN
+#ifdef __APPLE__
-/** converts a 32bit integer from big endian to host byte order */
+#include <libkern/OSByteOrder.h>
+
+/** Converts a 32bit integer from host byte order to big endian */
+#define htobe32(x) OSSwapHostToBigInt32(x)
+
+/** Converts a 32bit integer from host byte order to little endian */
+#define htole32(x) OSSwapHostToLittleInt32(x)
+
+/** Converts a 32bit integer from big endian to host byte order */
+#define be32toh(x) OSSwapBigToHostInt32(x)
+
+/** Converts a 32bit integer from little endian to host byte order */
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#elif !defined(HAVE_LINUX_ENDIAN)
+
+/** Converts a 32bit integer from big endian to host byte order */
#define be32toh(x) betoh32(x)
-/** converts a 32bit integer from little endian to host byte order */
+/** Converts a 32bit integer from little endian to host byte order */
#define le32toh(x) letoh32(x)
#endif