From d9301dd5ef76abb51251d68f086cdf54c9cbadb6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 3 May 2024 11:39:42 -0600 Subject: [PATCH] ccan/endian.h: Only define __{BIG,LITTLE}_ENDIAN if undefined. When both endian.h and ccan/endian/endian.h are included, we can have __{BIG,LITTLE}_ENDIAN redefined when compiling with clang on FreeBSD. Clang and gcc have moved to a predefine for endian orders. glibc defines these the same as they are defied here, but that's an unsafe assumption to make. Instead, only define them when __LITTLE_ENDIAN not defined as a fallback to when the host does not define them in the standard system headers. Signed-off-by: Warner Losh --- ccan/ccan/endian/endian.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccan/ccan/endian/endian.h b/ccan/ccan/endian/endian.h index 3753f490..ae96b51e 100644 --- a/ccan/ccan/endian/endian.h +++ b/ccan/ccan/endian/endian.h @@ -104,8 +104,10 @@ static inline uint64_t bswap_64(uint64_t val) #endif /* Needed for Glibc like endiness check */ +#ifndef __LITTLE_ENDIAN #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 +#endif /* Sanity check the defines. We don't handle weird endianness. */ #if !HAVE_LITTLE_ENDIAN && !HAVE_BIG_ENDIAN