Skip to content

Commit

Permalink
Add glibc style endianess check in CCAN
Browse files Browse the repository at this point in the history
CCAN adds support for glibc style in the following commit :
rustyrussell/ccan@759ac0f

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
Over-enthusiastic authored and stewartsmith committed Sep 19, 2017
1 parent d7631e5 commit 879f2ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ccan/endian/endian.h
Expand Up @@ -103,13 +103,22 @@ static inline uint64_t bswap_64(uint64_t val)
}
#endif

/* Needed for Glibc like endiness check */
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321

/* Sanity check the defines. We don't handle weird endianness. */
#if !HAVE_LITTLE_ENDIAN && !HAVE_BIG_ENDIAN
#error "Unknown endian"
#elif HAVE_LITTLE_ENDIAN && HAVE_BIG_ENDIAN
#error "Can't compile for both big and little endian."
#elif HAVE_LITTLE_ENDIAN
#define __BYTE_ORDER __LITTLE_ENDIAN
#elif HAVE_BIG_ENDIAN
#define __BYTE_ORDER __BIG_ENDIAN
#endif


#ifdef __CHECKER__
/* sparse needs forcing to remove bitwise attribute from ccan/short_types */
#define ENDIAN_CAST __attribute__((force))
Expand Down

0 comments on commit 879f2ce

Please sign in to comment.