[lttng-dev] [PATCH babeltrace 1/3] Port: Add OSX endian.h compat

Jérémie Galarneau jeremie.galarneau at efficios.com
Thu Feb 11 14:17:26 EST 2016


Merged, thanks!

Jérémie

On Thu, Nov 5, 2015 at 12:51 PM, Michael Jeanson <mjeanson at efficios.com> wrote:
> From: Alexis Martin <alexis.martin at inria.fr>
>
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
>  include/babeltrace/endian.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/include/babeltrace/endian.h b/include/babeltrace/endian.h
> index f0299ad..c5e5d70 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 <machine/endian.h>
> +# include <libkern/OSByteOrder.h>
> +
> +# 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 <endian.h>
>
> --
> 1.9.1
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list