From 50ec4d1ae06ec8968e0e068123eb3cae9dd562b9 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 3 Aug 2016 14:21:36 -0400 Subject: [PATCH] Port: Add OSX endian.h compat MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- src/common/compat/endian.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h index a8c500bd0..4edc12435 100644 --- a/src/common/compat/endian.h +++ b/src/common/compat/endian.h @@ -149,6 +149,43 @@ #define htobe64(x) BE_64(x) #define be64toh(x) BE_64(x) +#elif defined(__APPLE__) +# include +# include + +# if BYTE_ORDER == LITTLE_ENDIAN +# define htobe16(x) OSSwapConstInt16(x) +# define htole16(x) (x) +# define be16toh(x) OSSwapConstInt16(x) +# define le16toh(x) (x) + +# define htobe32(x) OSSwapConstInt32(x) +# define htole32(x) (x) +# define be32toh(x) OSSwapConstInt32(x) +# define le32toh(x) (x) + +# define htobe64(x) OSSwapConstInt64(x) +# define htole64(x) (x) +# define be64toh(x) OSSwapConstInt64(x) +# define le64toh(x) (x) + +# else /* BYTE_ORDER == LITTLE_ENDIAN */ +# define htobe16(x) (x) +# define htole16(x) OSSwapConstInt16(x) +# define be16toh(x) (x) +# define le16toh(x) OSSwapConstInt16(x) + +# define htobe32(x) (x) +# define htole32(x) OSSwapConstInt32(x) +# define be32toh(x) (x) +# define le32toh(x) OSSwapConstInt32(x) + +# define htobe64(x) (x) +# define htole64(x) OSSwapConstInt64(x) +# define be64toh(x) (x) +# define le64toh(x) OSSwapConstInt64(x) +# endif + #else #error "Please add support for your OS." #endif -- 2.34.1