]> granicus.if.org Git - pdns/commitdiff
define endianness macros for OS X portability
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 19 Nov 2015 09:15:32 +0000 (10:15 +0100)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 19 Nov 2015 11:28:48 +0000 (12:28 +0100)
pdns/iputils.hh

index ddc84141638ef7b26dd671011c4bce8c5b6df291..5cd6f87808ce8d7fae6f0cedbbeb049fbaa7731b 100644 (file)
 
 #include "namespaces.hh"
 
+#ifdef __APPLE__
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+#endif
+
 union ComboAddress {
   struct sockaddr_in sin4;
   struct sockaddr_in6 sin6;