[Commits] SDL: Check for immintrin.h before using it in SDL_cpuinfo.h

libsdl.org revision control commits-owner at libsdl.org
Mon Dec 11 11:56:14 PST 2017


details:   https://hg.libsdl.org/SDL/rev/c4900725a75a
changeset: 11762:c4900725a75a
user:      Sam Lantinga <slouken at libsdl.org>
date:      Mon Dec 11 12:00:12 2017 -0800
description:
Check for immintrin.h before using it in SDL_cpuinfo.h

diffstat:

 CMakeLists.txt             |   2 ++
 configure                  |  14 ++++++++++++++
 configure.in               |   7 +++++++
 include/SDL_config.h.cmake |   9 +++++----
 include/SDL_config.h.in    |   9 +++++----
 include/SDL_cpuinfo.h      |  18 +++++++++++++++++-
 6 files changed, 50 insertions(+), 9 deletions(-)

diffs (124 lines):

diff -r 74f570e0b634 -r c4900725a75a CMakeLists.txt
--- a/CMakeLists.txt	Mon Dec 11 11:47:52 2017 -0800
+++ b/CMakeLists.txt	Mon Dec 11 12:00:12 2017 -0800
@@ -580,6 +580,8 @@
       endif()
     endif()
 
+    check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
+
     if(ALTIVEC)
       set(CMAKE_REQUIRED_FLAGS "-maltivec")
       check_c_source_compiles("
diff -r 74f570e0b634 -r c4900725a75a configure
--- a/configure	Mon Dec 11 11:47:52 2017 -0800
+++ b/configure	Mon Dec 11 12:00:12 2017 -0800
@@ -17396,6 +17396,20 @@
         fi
     fi
 
+    ac_fn_c_check_header_mongrel "$LINENO" "immintrin.h" "ac_cv_header_immintrin_h" "$ac_includes_default"
+if test "x$ac_cv_header_immintrin_h" = xyes; then :
+  have_immintrin_h_hdr=yes
+else
+  have_immintrin_h_hdr=no
+fi
+
+
+    if test x$have_immintrin_h_hdr = xyes; then
+
+$as_echo "#define HAVE_IMMINTRIN_H 1" >>confdefs.h
+
+    fi
+
     # Check whether --enable-altivec was given.
 if test "${enable_altivec+set}" = set; then :
   enableval=$enable_altivec;
diff -r 74f570e0b634 -r c4900725a75a configure.in
--- a/configure.in	Mon Dec 11 11:47:52 2017 -0800
+++ b/configure.in	Mon Dec 11 12:00:12 2017 -0800
@@ -670,6 +670,13 @@
         fi
     fi
 
+    AC_CHECK_HEADER(immintrin.h,
+                    have_immintrin_h_hdr=yes,
+                    have_immintrin_h_hdr=no)
+    if test x$have_immintrin_h_hdr = xyes; then
+        AC_DEFINE(HAVE_IMMINTRIN_H, 1, [ ])
+    fi
+
     AC_ARG_ENABLE(altivec,
 AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
                   , enable_altivec=yes)
diff -r 74f570e0b634 -r c4900725a75a include/SDL_config.h.cmake
--- a/include/SDL_config.h.cmake	Mon Dec 11 11:47:52 2017 -0800
+++ b/include/SDL_config.h.cmake	Mon Dec 11 12:00:12 2017 -0800
@@ -191,11 +191,12 @@
 #endif /* HAVE_LIBC */
 
 #cmakedefine HAVE_ALTIVEC_H 1
+#cmakedefine HAVE_DBUS_DBUS_H 1
+#cmakedefine HAVE_FCITX_FRONTEND_H 1
+#cmakedefine HAVE_IBUS_IBUS_H 1
+#cmakedefine HAVE_IMMINTRIN_H 1
+#cmakedefine HAVE_LIBSAMPLERATE_H 1
 #cmakedefine HAVE_LIBUDEV_H 1
-#cmakedefine HAVE_DBUS_DBUS_H 1
-#cmakedefine HAVE_IBUS_IBUS_H 1
-#cmakedefine HAVE_FCITX_FRONTEND_H 1
-#cmakedefine HAVE_LIBSAMPLERATE_H 1
 
 #cmakedefine HAVE_D3D_H @HAVE_D3D_H@
 #cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
diff -r 74f570e0b634 -r c4900725a75a include/SDL_config.h.in
--- a/include/SDL_config.h.in	Mon Dec 11 11:47:52 2017 -0800
+++ b/include/SDL_config.h.in	Mon Dec 11 12:00:12 2017 -0800
@@ -193,11 +193,12 @@
 #endif /* HAVE_LIBC */
 
 #undef HAVE_ALTIVEC_H
+#undef HAVE_DBUS_DBUS_H
+#undef HAVE_FCITX_FRONTEND_H
+#undef HAVE_IBUS_IBUS_H
+#undef HAVE_IMMINTRIN_H
+#undef HAVE_LIBSAMPLERATE_H
 #undef HAVE_LIBUDEV_H
-#undef HAVE_DBUS_DBUS_H
-#undef HAVE_IBUS_IBUS_H
-#undef HAVE_FCITX_FRONTEND_H
-#undef HAVE_LIBSAMPLERATE_H
 
 #undef HAVE_DDRAW_H
 #undef HAVE_DINPUT_H
diff -r 74f570e0b634 -r c4900725a75a include/SDL_cpuinfo.h
--- a/include/SDL_cpuinfo.h	Mon Dec 11 11:47:52 2017 -0800
+++ b/include/SDL_cpuinfo.h	Mon Dec 11 12:00:12 2017 -0800
@@ -59,10 +59,26 @@
 #ifdef __3dNOW__
 #include <mm3dnow.h>
 #endif
-#if defined(__i386__) || defined(__x86_64__)
+#if HAVE_IMMINTRIN_H
 #include <immintrin.h>
+#else
+#ifdef __MMX__
+#include <mmintrin.h>
 #endif
+#ifdef __3dNOW__
+#include <mm3dnow.h>
 #endif
+#ifdef __SSE__
+#include <xmmintrin.h>
+#endif
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+#ifdef __SSE3__
+#include <pmmintrin.h>
+#endif
+#endif /* HAVE_IMMINTRIN_H */
+#endif /* compiler version */
 
 #include "begin_code.h"
 /* Set up for C function definitions, even when using C++ */


More information about the commits mailing list