From d625f37a7231b7347dcb59a1f7e8ff8aa9cff595 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 19 Jul 2022 19:09:58 +0200 Subject: Use predefined macros to figure out endianness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/common.h b/common.h index 7eab3b9..dce817a 100644 --- a/common.h +++ b/common.h @@ -52,9 +52,37 @@ # define HAS_BUILTIN(X) 0 #endif -#if defined(__x86_64__) || defined(__i386__) -# define LITTLE_ENDIAN -#else +#ifndef LIBBLAKE_ENDIAN_KNOWN__ +# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define LITTLE_ENDIAN +# define LIBBLAKE_ENDIAN_KNOWN__ +# endif +# endif +#endif +#ifndef LIBBLAKE_ENDIAN_KNOWN__ +# if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) +# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define BIG_ENDIAN +# define LIBBLAKE_ENDIAN_KNOWN__ +# endif +# endif +#endif +#ifndef LIBBLAKE_ENDIAN_KNOWN__ +# if defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) +# if __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__ +# define PDP_ENDIAN +# define LIBBLAKE_ENDIAN_KNOWN__ +# endif +# endif +#endif +#ifndef LIBBLAKE_ENDIAN_KNOWN__ +# if defined(__x86_64__) || defined(__i386__) +# define LITTLE_ENDIAN +# define LIBBLAKE_ENDIAN_KNOWN__ +# endif +#endif +#ifndef LIBBLAKE_ENDIAN_KNOWN__ # error Endian is unknown #endif -- cgit v1.2.3-70-g09d2