summaryrefslogtreecommitdiff
path: root/code/crypto/include/machine
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2017-05-03 21:10:08 +0200
committerUros Majstorovic <majstor@majstor.org>2017-05-03 21:10:08 +0200
commit25de5e761daab8b897a4f09ff8503e6f43c299f9 (patch)
treea9a1c185c7f89d67f9250e42b2aa53eefc9a6770 /code/crypto/include/machine
initial commit
Diffstat (limited to 'code/crypto/include/machine')
-rw-r--r--code/crypto/include/machine/endian.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/code/crypto/include/machine/endian.h b/code/crypto/include/machine/endian.h
new file mode 100644
index 0000000..5ec39af
--- /dev/null
+++ b/code/crypto/include/machine/endian.h
@@ -0,0 +1,40 @@
+/*
+ * Public domain
+ * machine/endian.h compatibility shim
+ */
+
+#ifndef LIBCRYPTOCOMPAT_BYTE_ORDER_H_
+#define LIBCRYPTOCOMPAT_BYTE_ORDER_H_
+
+#if defined(_WIN32)
+
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+#define PDP_ENDIAN 3412
+
+/*
+ * Use GCC and Visual Studio compiler defines to determine endian.
+ */
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define BYTE_ORDER LITTLE_ENDIAN
+#else
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+
+#elif defined(__linux__)
+#include <endian.h>
+
+#elif defined(__sun) || defined(_AIX) || defined(__hpux)
+#include <sys/types.h>
+#include <arpa/nameser_compat.h>
+
+#elif defined(__sgi)
+#include <standards.h>
+#include <sys/endian.h>
+
+#else
+#include_next <machine/endian.h>
+
+#endif
+
+#endif