From b8878682a49fcdd5952a9b8d7fc57eb1508a8adc Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 29 Nov 2018 13:24:34 -0800 Subject: macOS: fix endian macros for macOS. I've also flipped the `#if` because `#ifdef` feels more naturally readable than #ifndef when there's also a `#else`. (I've preserved the oddness of the clearenv declaration being here, because there isn't currently a more suitable `#ifdef __APPLE__` to move it too. Later...) --- lib/portability.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/portability.h') diff --git a/lib/portability.h b/lib/portability.h index 2dba2311..3f841bac 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -98,20 +98,28 @@ char *strcasestr(const char *haystack, const char *needle); // Work out how to do endianness -#ifndef __APPLE__ -#include -#include +#ifdef __APPLE__ -#if __BYTE_ORDER == __BIG_ENDIAN +#include + +#ifdef __BIG_ENDIAN__ #define IS_BIG_ENDIAN 1 #else #define IS_BIG_ENDIAN 0 #endif +#define bswap_16(x) OSSwapInt16(x) +#define bswap_32(x) OSSwapInt32(x) +#define bswap_64(x) OSSwapInt64(x) + int clearenv(void); + #else -#ifdef __BIG_ENDIAN__ +#include +#include + +#if __BYTE_ORDER == __BIG_ENDIAN #define IS_BIG_ENDIAN 1 #else #define IS_BIG_ENDIAN 0 -- cgit v1.2.3