diff options
author | Mattias Andrée <maandree@kth.se> | 2022-07-19 19:09:58 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-07-19 19:09:58 +0200 |
commit | d625f37a7231b7347dcb59a1f7e8ff8aa9cff595 (patch) | |
tree | c0c1ee26c5bd491c79c9a6a6a67aa72547541915 | |
parent | m (diff) | |
download | libblake-d625f37a7231b7347dcb59a1f7e8ff8aa9cff595.tar.gz libblake-d625f37a7231b7347dcb59a1f7e8ff8aa9cff595.tar.bz2 libblake-d625f37a7231b7347dcb59a1f7e8ff8aa9cff595.tar.xz |
Use predefined macros to figure out endianness
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | common.h | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -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 |