From dd9bd206c65f877b86ad33c02a543272c5acf876 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 16 Jan 2015 10:12:30 +0000 Subject: [PATCH] Old glibc doesn't provide these macros, so we have to define them. Signed-off-by: Mikulas Patocka --- base/endian_utils.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/base/endian_utils.h b/base/endian_utils.h index 3ad75ae..82b5b59 100644 --- a/base/endian_utils.h +++ b/base/endian_utils.h @@ -25,6 +25,26 @@ //---------------------------------------------------------------- +/* An old glic doesn't provide these macros */ +#if !defined(htole16) || !defined(le16toh) || !defined(htole32) || !defined(le32toh) || !defined(htole64) || !defined(le64toh) +#include +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define htole16(x) (x) +#define le16toh(x) (x) +#define htole32(x) (x) +#define le32toh(x) (x) +#define htole64(x) (x) +#define le64toh(x) (x) +#else +#define htole16(x) __bswap_16(x) +#define le16toh(x) __bswap_16(x) +#define htole32(x) __bswap_32(x) +#define le32toh(x) __bswap_32(x) +#define htole64(x) __bswap_64(x) +#define le64toh(x) __bswap_64(x) +#endif +#endif + namespace base { // These are just little wrapper types to make the compiler