diff options
author | Martin Willi <martin@strongswan.org> | 2015-11-10 08:12:35 +0100 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2015-12-04 10:29:09 +0100 |
commit | 057e6cc52466327dba7b9e21a472ef9f4028f118 (patch) | |
tree | e3e1948688aaf7aa78c36709efb5a46d274ea2fb /src | |
parent | 8fa0c7bc77203f5aa8a4e9507b11a55e34200684 (diff) | |
download | strongswan-057e6cc52466327dba7b9e21a472ef9f4028f118.tar.bz2 strongswan-057e6cc52466327dba7b9e21a472ef9f4028f118.tar.xz |
byteorder: Provide a fallback for le32toh/htole32()
Some older toolchains don't provide these macros, so implement them using
the gcc builtins. We also provide 64-bit variants as used by chapoly.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/utils/utils/byteorder.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/utils/byteorder.h b/src/libstrongswan/utils/utils/byteorder.h index ef2bddbf7..68a7b3363 100644 --- a/src/libstrongswan/utils/utils/byteorder.h +++ b/src/libstrongswan/utils/utils/byteorder.h @@ -158,6 +158,26 @@ static inline u_int64_t untoh64(void *network) #endif } +#ifndef le32toh +# if BYTE_ORDER == BIG_ENDIAN +# define le32toh(x) __builtin_bswap32(x) +# define htole32(x) __builtin_bswap32(x) +# else +# define le32toh(x) (x) +# define htole32(x) (x) +# endif +#endif + +#ifndef le64toh +# if BYTE_ORDER == BIG_ENDIAN +# define le64toh(x) __builtin_bswap64(x) +# define htole64(x) __builtin_bswap64(x) +# else +# define le64toh(x) (x) +# define htole64(x) (x) +# endif +#endif + /** * Read a 32-bit value in little-endian order from unaligned address. * |