endian: WORDS_UNALIGNED_ACCESS_OK (draft)
authorMarko Kreen <markokr@gmail.com>
Wed, 9 Jul 2014 17:03:55 +0000 (20:03 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 14 Jul 2014 11:01:18 +0000 (14:01 +0300)
Seems it might be useful (mainly inside endian.h) for non-gcc/clang
compilers, but needs proof.

usual/endian.h

index 58d44e22a86515280fc1dd31794c5f43543ef5ec..8291cdebe5c01cd900309b42e549b6ed1f6e2788 100644 (file)
 #include <byteswap.h>
 #endif
 
+/*
+ * Is unaligned access to integers OK?  Does not apply to floats.
+ *
+ * OK: x86, amd64, arm >= v6, ppc
+ */
+#if defined(__amd64__) || defined(__i386__) || defined(__ppc__) || defined(__ppc64__) \
+       || defined(__ARM_FEATURE_UNALIGNED) \
+       || defined(_M_IX86) || defined(_M_X64) || defined(_M_PPC) \
+       || (defined(_M_ARM) && _M_ARM >= 6)
+#define WORDS_UNALIGNED_ACCESS_OK
+#endif
 
 /*
  * Ignore OS defines, as they may define only some subset of functions.