From: Michael Jeanson Date: Wed, 16 Mar 2022 15:40:52 +0000 (-0400) Subject: Fix: use the correct endian compat macros X-Git-Tag: v2.12.9~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bd5637954920c9b2c48600638f966247a2f5d4ef;p=lttng-tools.git Fix: use the correct endian compat macros Document which variant of the endian macros our compat header guarantees across all platforms and fix incorrect uses. This was discovered with -Wundef on macOS. Change-Id: Iaf442fe5887063661273ac2a00c9fa4015e83d5c Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h index 652802a67..f57b6d4a4 100644 --- a/src/common/compat/endian.h +++ b/src/common/compat/endian.h @@ -5,6 +5,35 @@ * */ +/* + * This compat header provides the following defines: + * + * LITTLE_ENDIAN + * BIG_ENDIAN + * BYTE_ORDER + * + * And functions / macros : + * + * bswap_16() + * bswap_32() + * bswap_64() + * + * htobe16() + * htole16() + * be16toh() + * le16toh() + * + * htobe32() + * htole32() + * be32toh() + * le32toh() + * + * htobe64() + * htole64() + * be64toh() + * le64toh() + */ + #ifndef _COMPAT_ENDIAN_H #define _COMPAT_ENDIAN_H @@ -123,7 +152,6 @@ #define LITTLE_ENDIAN __LITTLE_ENDIAN #define BIG_ENDIAN __BIG_ENDIAN -#define PDP_ENDIAN __PDP_ENDIAN #define BYTE_ORDER __BYTE_ORDER #define betoh16(x) BE_16(x) diff --git a/src/common/hashtable/utils.c b/src/common/hashtable/utils.c index 580769563..60ac8c9e6 100644 --- a/src/common/hashtable/utils.c +++ b/src/common/hashtable/utils.c @@ -57,14 +57,14 @@ * My best guess at if you are big-endian or little-endian. This may * need adjustment. */ -#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \ - __BYTE_ORDER == __LITTLE_ENDIAN) || \ +#if (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && \ + BYTE_ORDER == LITTLE_ENDIAN) || \ (defined(i386) || defined(__i386__) || defined(__i486__) || \ defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL)) # define HASH_LITTLE_ENDIAN 1 # define HASH_BIG_ENDIAN 0 -#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \ - __BYTE_ORDER == __BIG_ENDIAN) || \ +#elif (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && \ + BYTE_ORDER == BIG_ENDIAN) || \ (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel)) # define HASH_LITTLE_ENDIAN 0 # define HASH_BIG_ENDIAN 1