From: Warner Losh Date: Fri, 3 May 2024 17:39:42 +0000 (-0600) Subject: ccan/endian.h: Only define __{BIG,LITTLE}_ENDIAN if undefined. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=26b0eaf36828082e8d895138cd0e106e5be32cf4;p=users%2Fsagi%2Flibnvme.git 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 --- 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