From 64257e6eae4e5e73052c8249316df08b91a2445a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 3 Sep 2014 17:54:36 +0200 Subject: Fix UHASH build on MacOS X --- src/util.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/util.h') 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 + +/** 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 -- cgit v1.2.3