X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fendian.h;h=6427feb8df3e8aa032627299fde8f134116f3365;hb=18710679a8ac57fda5dbd26cf16bb180dce9e286;hp=a8c500bd0529f43a255857b8276b74d72f5b65ec;hpb=0c97bd7a3786cef6aad854a9cc10ed7e299508c2;p=lttng-tools.git diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h index a8c500bd0..6427feb8d 100644 --- a/src/common/compat/endian.h +++ b/src/common/compat/endian.h @@ -18,7 +18,7 @@ #ifndef _COMPAT_ENDIAN_H #define _COMPAT_ENDIAN_H -#ifdef __linux__ +#if defined(__linux__) || defined(__CYGWIN__) #include /* @@ -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