aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-19 19:09:58 +0200
committerMattias Andrée <maandree@kth.se>2022-07-19 19:09:58 +0200
commitd625f37a7231b7347dcb59a1f7e8ff8aa9cff595 (patch)
treec0c1ee26c5bd491c79c9a6a6a67aa72547541915
parentm (diff)
downloadlibblake-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.h34
1 files 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