diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-03-15 00:45:16 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-03-15 23:15:11 +0100 |
commit | befbb6924ccc31df1dc82d1ad1e18f9baf11aa23 (patch) | |
tree | c4a5152998f3b010be069aad7ce751ba9fbadc3c /include | |
parent | 49838a84f557688a21a24292504021a63992b92c (diff) |
include: add OS X compatible endian.h header
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-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 |