SDL: include: include intrinsics headers for RDTSC SSE4.1 and SSE4.2

From cb46cbe684717061a0c7ecd86bb164e81538a0fd Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 20 Mar 2023 23:48:01 +0100
Subject: [PATCH] include: include intrinsics headers for RDTSC SSE4.1 and
 SSE4.2

---
 include/SDL3/SDL_intrin.h | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/include/SDL3/SDL_intrin.h b/include/SDL3/SDL_intrin.h
index 15832383de10..09172b79fe31 100644
--- a/include/SDL3/SDL_intrin.h
+++ b/include/SDL3/SDL_intrin.h
@@ -108,29 +108,46 @@ _m_prefetch(void *__P)
 #endif
 
 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
-# if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX)
-#  define SDL_AVX_INTRINSICS
-#  include <immintrin.h>
+# if ((defined(__GNUC__) && (__GNUC__ >= 10)) || (defined(__clang__) && __clang_major__ >= 4) || defined(_MSC_VER)) && !defined(SDL_DISABLE_RDTSC)
+#  define SDL_RDTSC_INTRINSICS 1
+#  if defined(_MSC_VER)
+#   include <intrin.h>
+#  else
+#   include <immintrin.h>
+#  endif
 # endif
 # if ((defined(_MSC_VER) && !defined(_M_X64)) || defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
 #  define SDL_MMX_INTRINSICS 1
 #  include <mmintrin.h>
 # endif
 # if (defined(_MSC_VER) || defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE)
-   /* x86 MSVC defines _M_IX86_FP == 1 when compiled with /arch:SSE */
 #  define SDL_SSE_INTRINSICS 1
 #  include <xmmintrin.h>
 # endif
 # if (defined(_MSC_VER) || defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2)
-   /* x86 MSVC defines _M_IX86_FP == 2 when compiled with /arch:SSE2 */
 #  define SDL_SSE2_INTRINSICS 1
 #  include <emmintrin.h>
 # endif
 # if (defined(_MSC_VER) || defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3)
-   /* x86 MSVC does not provide macro's to detect SSE3/SSE4 */
 #  define SDL_SSE3_INTRINSICS 1
 #  include <pmmintrin.h>
 # endif
+# if (defined(_MSC_VER) || defined(__SSE4_1__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE42)
+#  define SDL_SSE4_1_INTRINSICS 1
+#  include <smmintrin.h>
+# endif
+# if (defined(_MSC_VER) || defined(__SSE4_2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE42)
+#  define SDL_SSE4_2_INTRINSICS 1
+#  include <nmmintrin.h>
+# endif
+# if (defined(_MSC_VER) || defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX)
+#  define SDL_AVX_INTRINSICS 1
+#  include <immintrin.h>
+# endif
+# if (defined(_MSC_VER) || defined(__AVX512F__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX512F)
+#  define SDL_AVX512F_INTRINSICS 1
+#  include <immintrin.h>
+# endif
 #endif /* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */
 
 #endif /* SDL_intrin_h_ */