aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'common.h')
-rw-r--r--common.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/common.h b/common.h
index e02d2c6..8863661 100644
--- a/common.h
+++ b/common.h
@@ -54,6 +54,28 @@
#endif
+#define LITTLE_ENDIAN__ 1234
+#define BIG_ENDIAN__ 4321
+#ifndef HOST_ENDIAN
+# if defined(i386) || defined(__i386__) || defined(__x86_64__)
+# define HOST_ENDIAN LITTLE_ENDIAN__
+# endif
+#endif
+#ifdef HOST_ENDIAN
+# if HOST_ENDIAN == LITTLE_ENDIAN__
+# define USING_LITTLE_ENDIAN
+# elif HOST_ENDIAN == BIG_ENDIAN__
+# define USING_BIG_ENDIAN
+# endif
+#else
+# ifdef __GNUC__
+# ifdef WARN_UNKNOWN_ENDIAN
+# warning The host endian is unknown
+# endif
+# endif
+#endif
+
+
#define ELEMSOF(ARR) (sizeof(ARR) / sizeof(*(ARR)))
#define MAX(A, B) ((A) > (B) ? (A) : (B))