Check for immintrin.h before using it in SDL_cpuinfo.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bfda8a1..aa5cc0c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -580,6 +580,8 @@ if(ASSEMBLY)
endif()
endif()
+ check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
+
if(ALTIVEC)
set(CMAKE_REQUIRED_FLAGS "-maltivec")
check_c_source_compiles("
diff --git a/configure b/configure
index 0cebb09..ff5f7fc 100755
--- a/configure
+++ b/configure
@@ -17396,6 +17396,20 @@ $as_echo "$have_gcc_sse3" >&6; }
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 --git a/configure.in b/configure.in
index 839f2ec..fd0224c 100644
--- a/configure.in
+++ b/configure.in
@@ -670,6 +670,13 @@ AC_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
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 --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 7c2c0ca..a55dcbd 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -191,11 +191,12 @@
#endif /* HAVE_LIBC */
#cmakedefine HAVE_ALTIVEC_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_IBUS_IBUS_H 1
+#cmakedefine HAVE_IMMINTRIN_H 1
#cmakedefine HAVE_LIBSAMPLERATE_H 1
+#cmakedefine HAVE_LIBUDEV_H 1
#cmakedefine HAVE_D3D_H @HAVE_D3D_H@
#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 1cfcde4..71f746a 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -193,11 +193,12 @@
#endif /* HAVE_LIBC */
#undef HAVE_ALTIVEC_H
-#undef HAVE_LIBUDEV_H
#undef HAVE_DBUS_DBUS_H
-#undef HAVE_IBUS_IBUS_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_DDRAW_H
#undef HAVE_DINPUT_H
diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h
index 1fde4e6..c7958a4 100644
--- a/include/SDL_cpuinfo.h
+++ b/include/SDL_cpuinfo.h
@@ -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++ */