diff mbox series

[v4,2/8] Add glibc style endianess check in CCAN

Message ID 1505460876-7303-3-git-send-email-akshay.adiga@linux.vnet.ibm.com
State Superseded
Headers show
Series Enable stop4 idle state | expand

Commit Message

Akshay Adiga Sept. 15, 2017, 7:34 a.m. UTC
CCAN adds support for glibc style in the following commit :
https://github.com/rustyrussell/ccan/commit/759ac0f0564104d5028acd47c3e9fdb858c96d1d

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
---
 ccan/endian/endian.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Vaidyanathan Srinivasan Sept. 15, 2017, 8:24 a.m. UTC | #1
* Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> [2017-09-15 13:04:30]:

> CCAN adds support for glibc style in the following commit :
> https://github.com/rustyrussell/ccan/commit/759ac0f0564104d5028acd47c3e9fdb858c96d1d
> 
> Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>

Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>


> ---
>  ccan/endian/endian.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/ccan/endian/endian.h b/ccan/endian/endian.h
> index 0c99cc8..6732e8a 100644
> --- a/ccan/endian/endian.h
> +++ b/ccan/endian/endian.h
> @@ -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))
> -- 
> 2.5.5
>
diff mbox series

Patch

diff --git a/ccan/endian/endian.h b/ccan/endian/endian.h
index 0c99cc8..6732e8a 100644
--- a/ccan/endian/endian.h
+++ b/ccan/endian/endian.h
@@ -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))