diff options
author | Ruediger Meier | 2016-03-08 10:35:58 +0100 |
---|---|---|
committer | Ruediger Meier | 2016-03-08 14:55:38 +0100 |
commit | d20eb029d52b6cd31b2a86b95d2708f505eca78a (patch) | |
tree | 47af01fc1293fe15736a95bfc96bd97425d8f5f3 | |
parent | include/bitops: add casts to bswap functions (diff) | |
download | kernel-qcow2-util-linux-d20eb029d52b6cd31b2a86b95d2708f505eca78a.tar.gz kernel-qcow2-util-linux-d20eb029d52b6cd31b2a86b95d2708f505eca78a.tar.xz kernel-qcow2-util-linux-d20eb029d52b6cd31b2a86b95d2708f505eca78a.zip |
include/bitops: avoid fallbacks for more systems
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
-rw-r--r-- | include/bitops.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/bitops.h b/include/bitops.h index 2d2f88d9c..287d4af29 100644 --- a/include/bitops.h +++ b/include/bitops.h @@ -25,6 +25,27 @@ # define be16toh(x) betoh16(x) # define be32toh(x) betoh32(x) # define be64toh(x) betoh64(x) +#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) +# define bswap_16(x) bswap16(x) +# define bswap_32(x) bswap32(x) +# define bswap_64(x) bswap64(x) +#elif defined(__APPLE__) +# 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) +# define bswap_16(x) OSSwapInt16(x) +# define bswap_32(x) OSSwapInt32(x) +# define bswap_64(x) OSSwapInt64(x) #endif /* |