From: Rusty Russell Date: Thu, 10 May 2018 02:25:59 +0000 (+0930) Subject: endian: fix compilation with musl libc. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=696c9b68f6334835f13037a83dd5a11c1c8129c7;hp=5a15d1aaa373ca2ffe9cd99f75d42e4a8ed4e4e9 endian: fix compilation with musl libc. It defines __BYTE_ORDER to __BYTE_ORDER__; gcc complains when we define it to something else. Let it be already defined, but check that the value is what we expect. Signed-off-by: Rusty Russell --- diff --git a/ccan/endian/endian.h b/ccan/endian/endian.h index 6732e8aa..3753f490 100644 --- a/ccan/endian/endian.h +++ b/ccan/endian/endian.h @@ -113,9 +113,17 @@ static inline uint64_t bswap_64(uint64_t val) #elif HAVE_LITTLE_ENDIAN && HAVE_BIG_ENDIAN #error "Can't compile for both big and little endian." #elif HAVE_LITTLE_ENDIAN +#ifndef __BYTE_ORDER #define __BYTE_ORDER __LITTLE_ENDIAN +#elif __BYTE_ORDER != __LITTLE_ENDIAN +#error "__BYTE_ORDER already defined, but not equal to __LITTLE_ENDIAN" +#endif #elif HAVE_BIG_ENDIAN +#ifndef __BYTE_ORDER #define __BYTE_ORDER __BIG_ENDIAN +#elif __BYTE_ORDER != __BIG_ENDIAN +#error "__BYTE_ORDER already defined, but not equal to __BIG_ENDIAN" +#endif #endif