gstconfig.h: Detect unaligned access support at compile-time
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 21 Jun 2016 13:29:49 +0000 (18:59 +0530)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 13 Aug 2016 09:29:31 +0000 (10:29 +0100)
This makes gstconfig.h completely arch-independent. Should cover all
compilers that gstreamer is known to build on, and all architectures
that I could find information on. People are encouraged to file bugs if
their platform/arch is missing.

configure.ac
gst/gstconfig.h.in

index e116a73..f663bf3 100644 (file)
@@ -411,17 +411,6 @@ dnl substitution for win32/common/config.h
 HOST_CPU=$host_cpu
 AC_SUBST(HOST_CPU)
 
-dnl common/m4/gst-arch.m4
-dnl check for unaligned access
-AG_GST_UNALIGNED_ACCESS
-dnl create a configure variable for gst/gstconfig.h
-if test x${as_cv_unaligned_access} = xyes ; then
-  GST_HAVE_UNALIGNED_ACCESS_DEFINE="#define GST_HAVE_UNALIGNED_ACCESS 1"
-else
-  GST_HAVE_UNALIGNED_ACCESS_DEFINE="#define GST_HAVE_UNALIGNED_ACCESS 0"
-fi
-AC_SUBST(GST_HAVE_UNALIGNED_ACCESS_DEFINE)
-
 dnl check for platform specific settings
 AG_GST_PLATFORM
 
index 8654627..0ec1509 100644 (file)
 /* Configures the use of external plugins */
 @GST_DISABLE_PLUGIN_DEFINE@
 
-/* whether or not the CPU supports unaligned access */
-@GST_HAVE_UNALIGNED_ACCESS_DEFINE@
+/* Whether or not the CPU supports unaligned access
+ * The macros used are defined consistently by GCC, Clang, MSVC, Sun, and ICC
+ *
+ * References:
+ * https://sourceforge.net/p/predef/wiki/Architectures/
+ * https://msdn.microsoft.com/en-us/library/b0084kay.aspx
+ * http://docs.oracle.com/cd/E19205-01/820-4155/c++_faq.html#Vers6
+ * https://software.intel.com/en-us/node/583402
+ */
+#if defined(__alpha__) || defined(__arm__) || defined(__aarch64__) || defined(__bfin) || defined(__hppa__) || defined(__mips__) || defined(__sh__) || defined(__sparc__) || defined(__sparc) || defined(__ia64__) || defined(_M_ALPHA) || defined(_M_ARM) || defined(_M_IA64)
+#  define GST_HAVE_UNALIGNED_ACCESS 0
+#elif defined(__i386__) || defined(__i386) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__ppc__) || defined(__ppc64__) || defined(__m68k__) || defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)
+#  define GST_HAVE_UNALIGNED_ACCESS 1
+#else
+#  error "Could not detect architecture; don't know whether it supports unaligned access! Please file a bug."
+#endif
 
 /**
  * GST_EXPORT: