Check for immintrin.h before using it in SDL_cpuinfo.h
authorSam Lantinga <slouken@libsdl.org>
Mon, 11 Dec 2017 12:00:12 -0800
changeset 11762c4900725a75a
parent 11761 74f570e0b634
child 11763 5c8fc26757d7
Check for immintrin.h before using it in SDL_cpuinfo.h
CMakeLists.txt
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_cpuinfo.h
     1.1 --- a/CMakeLists.txt	Mon Dec 11 11:47:52 2017 -0800
     1.2 +++ b/CMakeLists.txt	Mon Dec 11 12:00:12 2017 -0800
     1.3 @@ -580,6 +580,8 @@
     1.4        endif()
     1.5      endif()
     1.6  
     1.7 +    check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
     1.8 +
     1.9      if(ALTIVEC)
    1.10        set(CMAKE_REQUIRED_FLAGS "-maltivec")
    1.11        check_c_source_compiles("
     2.1 --- a/configure	Mon Dec 11 11:47:52 2017 -0800
     2.2 +++ b/configure	Mon Dec 11 12:00:12 2017 -0800
     2.3 @@ -17396,6 +17396,20 @@
     2.4          fi
     2.5      fi
     2.6  
     2.7 +    ac_fn_c_check_header_mongrel "$LINENO" "immintrin.h" "ac_cv_header_immintrin_h" "$ac_includes_default"
     2.8 +if test "x$ac_cv_header_immintrin_h" = xyes; then :
     2.9 +  have_immintrin_h_hdr=yes
    2.10 +else
    2.11 +  have_immintrin_h_hdr=no
    2.12 +fi
    2.13 +
    2.14 +
    2.15 +    if test x$have_immintrin_h_hdr = xyes; then
    2.16 +
    2.17 +$as_echo "#define HAVE_IMMINTRIN_H 1" >>confdefs.h
    2.18 +
    2.19 +    fi
    2.20 +
    2.21      # Check whether --enable-altivec was given.
    2.22  if test "${enable_altivec+set}" = set; then :
    2.23    enableval=$enable_altivec;
     3.1 --- a/configure.in	Mon Dec 11 11:47:52 2017 -0800
     3.2 +++ b/configure.in	Mon Dec 11 12:00:12 2017 -0800
     3.3 @@ -670,6 +670,13 @@
     3.4          fi
     3.5      fi
     3.6  
     3.7 +    AC_CHECK_HEADER(immintrin.h,
     3.8 +                    have_immintrin_h_hdr=yes,
     3.9 +                    have_immintrin_h_hdr=no)
    3.10 +    if test x$have_immintrin_h_hdr = xyes; then
    3.11 +        AC_DEFINE(HAVE_IMMINTRIN_H, 1, [ ])
    3.12 +    fi
    3.13 +
    3.14      AC_ARG_ENABLE(altivec,
    3.15  AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
    3.16                    , enable_altivec=yes)
     4.1 --- a/include/SDL_config.h.cmake	Mon Dec 11 11:47:52 2017 -0800
     4.2 +++ b/include/SDL_config.h.cmake	Mon Dec 11 12:00:12 2017 -0800
     4.3 @@ -191,11 +191,12 @@
     4.4  #endif /* HAVE_LIBC */
     4.5  
     4.6  #cmakedefine HAVE_ALTIVEC_H 1
     4.7 +#cmakedefine HAVE_DBUS_DBUS_H 1
     4.8 +#cmakedefine HAVE_FCITX_FRONTEND_H 1
     4.9 +#cmakedefine HAVE_IBUS_IBUS_H 1
    4.10 +#cmakedefine HAVE_IMMINTRIN_H 1
    4.11 +#cmakedefine HAVE_LIBSAMPLERATE_H 1
    4.12  #cmakedefine HAVE_LIBUDEV_H 1
    4.13 -#cmakedefine HAVE_DBUS_DBUS_H 1
    4.14 -#cmakedefine HAVE_IBUS_IBUS_H 1
    4.15 -#cmakedefine HAVE_FCITX_FRONTEND_H 1
    4.16 -#cmakedefine HAVE_LIBSAMPLERATE_H 1
    4.17  
    4.18  #cmakedefine HAVE_D3D_H @HAVE_D3D_H@
    4.19  #cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@
     5.1 --- a/include/SDL_config.h.in	Mon Dec 11 11:47:52 2017 -0800
     5.2 +++ b/include/SDL_config.h.in	Mon Dec 11 12:00:12 2017 -0800
     5.3 @@ -193,11 +193,12 @@
     5.4  #endif /* HAVE_LIBC */
     5.5  
     5.6  #undef HAVE_ALTIVEC_H
     5.7 +#undef HAVE_DBUS_DBUS_H
     5.8 +#undef HAVE_FCITX_FRONTEND_H
     5.9 +#undef HAVE_IBUS_IBUS_H
    5.10 +#undef HAVE_IMMINTRIN_H
    5.11 +#undef HAVE_LIBSAMPLERATE_H
    5.12  #undef HAVE_LIBUDEV_H
    5.13 -#undef HAVE_DBUS_DBUS_H
    5.14 -#undef HAVE_IBUS_IBUS_H
    5.15 -#undef HAVE_FCITX_FRONTEND_H
    5.16 -#undef HAVE_LIBSAMPLERATE_H
    5.17  
    5.18  #undef HAVE_DDRAW_H
    5.19  #undef HAVE_DINPUT_H
     6.1 --- a/include/SDL_cpuinfo.h	Mon Dec 11 11:47:52 2017 -0800
     6.2 +++ b/include/SDL_cpuinfo.h	Mon Dec 11 12:00:12 2017 -0800
     6.3 @@ -59,10 +59,26 @@
     6.4  #ifdef __3dNOW__
     6.5  #include <mm3dnow.h>
     6.6  #endif
     6.7 -#if defined(__i386__) || defined(__x86_64__)
     6.8 +#if HAVE_IMMINTRIN_H
     6.9  #include <immintrin.h>
    6.10 +#else
    6.11 +#ifdef __MMX__
    6.12 +#include <mmintrin.h>
    6.13  #endif
    6.14 +#ifdef __3dNOW__
    6.15 +#include <mm3dnow.h>
    6.16  #endif
    6.17 +#ifdef __SSE__
    6.18 +#include <xmmintrin.h>
    6.19 +#endif
    6.20 +#ifdef __SSE2__
    6.21 +#include <emmintrin.h>
    6.22 +#endif
    6.23 +#ifdef __SSE3__
    6.24 +#include <pmmintrin.h>
    6.25 +#endif
    6.26 +#endif /* HAVE_IMMINTRIN_H */
    6.27 +#endif /* compiler version */
    6.28  
    6.29  #include "begin_code.h"
    6.30  /* Set up for C function definitions, even when using C++ */