From 1a7d971f334bcc8cff3e49a5a4afe5552f4254f0 Mon Sep 17 00:00:00 2001 From: Alexis Martin Date: Thu, 5 Nov 2015 12:51:53 -0500 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 --- include/babeltrace/endian.h | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/babeltrace/endian.h b/include/babeltrace/endian.h index 77686398..e6f20f4c 100644 --- a/include/babeltrace/endian.h +++ b/include/babeltrace/endian.h @@ -81,6 +81,44 @@ #define BIG_ENDIAN __BIG_ENDIAN #define PDP_ENDIAN __PDP_ENDIAN #define BYTE_ORDER __BYTE_ORDER + +#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 #include #endif -- 2.34.1