Skip to content

Commit

Permalink
Add __APPLE__ support to intern.h
Browse files Browse the repository at this point in the history
* add __APPLE__ support to intern.h to fix MacOS build

* fix kByteSwapData value
  • Loading branch information
hthetiot authored and usineur committed Apr 11, 2020
1 parent f0ff629 commit 0a79a81
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#define htole16(x) x
#define htole32(x) x
static const bool kByteSwapData = false; // no byteswap needed on little endian
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#include <machine/endian.h>
static const bool kByteSwapData = (BYTE_ORDER == BIG_ENDIAN);
#else
#include <endian.h>
static const bool kByteSwapData = (__BYTE_ORDER == __BIG_ENDIAN);
Expand Down

0 comments on commit 0a79a81

Please sign in to comment.