diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-03-20 23:34:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-20 23:34:56 +0100 |
commit | a88aca97633c2ec58987a76a5a8d910c37680e07 (patch) | |
tree | dee32d4bba166995bdb32d4cf8f1fcad8bcead4d /include/endian.h | |
parent | 807060a5d2d40113d9d78bf9e3866efb3de4c442 (diff) | |
parent | ab46fdfe742e754a8a56207ce1fc5653085696ad (diff) |
Merge pull request #52 from jow-/portability-fixes
Portability fixes for macOS
Diffstat (limited to 'include/endian.h')
-rw-r--r-- | include/endian.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/endian.h b/include/endian.h new file mode 100644 index 0000000..198cf7c --- /dev/null +++ b/include/endian.h @@ -0,0 +1,23 @@ +#ifdef __APPLE__ + +# include <machine/endian.h> +# include <libkern/OSByteOrder.h> + +# define htobe16(x) OSSwapHostToBigInt16(x) +# define htole16(x) OSSwapHostToLittleInt16(x) +# define be16toh(x) OSSwapBigToHostInt16(x) +# define le16toh(x) OSSwapLittleToHostInt16(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define htole32(x) OSSwapHostToLittleInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe64(x) OSSwapHostToBigInt64(x) +# define htole64(x) OSSwapHostToLittleInt64(x) +# define be64toh(x) OSSwapBigToHostInt64(x) +# define le64toh(x) OSSwapLittleToHostInt64(x) + +#else +# include_next <endian.h> +#endif |