From: Tobias Brunner Date: Fri, 4 Mar 2016 09:13:49 +0000 (+0100) Subject: byteorder: Always define be64toh/htobe64 macros X-Git-Tag: 5.4.0dr8~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14de79604a1b9ab77b7116c247d14f6be3009bdb;p=thirdparty%2Fstrongswan.git byteorder: Always define be64toh/htobe64 macros --- diff --git a/src/libstrongswan/utils/utils/byteorder.h b/src/libstrongswan/utils/utils/byteorder.h index 68a7b33636..53ec177a5c 100644 --- a/src/libstrongswan/utils/utils/byteorder.h +++ b/src/libstrongswan/utils/utils/byteorder.h @@ -44,6 +44,36 @@ #define BITFIELD5(t, a, b, c, d, e,...) struct { t e; t d; t c; t b; t a; __VA_ARGS__} #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 + +#ifndef be64toh +# if BYTE_ORDER == BIG_ENDIAN +# define be64toh(x) (x) +# define htobe64(x) (x) +# else +# define be64toh(x) __builtin_bswap64(x) +# define htobe64(x) __builtin_bswap64(x) +# endif +#endif + /** * Write a 16-bit host order value in network order to an unaligned address. * @@ -158,26 +188,6 @@ 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. *