SDL: SDL_intrin.h: define SDL_<simd>_INTRINSICS in user-visible header

From b5b9ddb2052e8ca7b9ef55d78c68e6af88305484 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 18 Mar 2023 17:15:37 +0100
Subject: [PATCH] SDL_intrin.h: define SDL_<simd>_INTRINSICS in user-visible
 header

---
 include/SDL3/SDL_intrin.h    | 53 ++++++++++++++++++++++++------------
 src/SDL_internal.h           | 41 ----------------------------
 src/audio/SDL_audiocvt.c     |  8 +++---
 src/audio/SDL_audiotypecvt.c | 16 +++++------
 src/video/SDL_blit_A.c       | 18 ++++++------
 src/video/SDL_blit_copy.c    | 12 ++++----
 src/video/SDL_fillrect.c     |  8 +++---
 src/video/SDL_stretch.c      | 12 ++++----
 src/video/SDL_yuv.c          | 30 ++++++++++----------
 src/video/yuv2rgb/yuv_rgb.c  |  8 +++---
 10 files changed, 91 insertions(+), 115 deletions(-)

diff --git a/include/SDL3/SDL_intrin.h b/include/SDL3/SDL_intrin.h
index d3fb696ff9c6..a01dfbecc8ea 100644
--- a/include/SDL3/SDL_intrin.h
+++ b/include/SDL3/SDL_intrin.h
@@ -66,24 +66,29 @@ _m_prefetch(void *__P)
 #elif defined(__MINGW64_VERSION_MAJOR)
 #include <intrin.h>
 #if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
+#  define SDL_NEON_INTRINSICS 1
 #  include <arm_neon.h>
 #endif
 #else
 /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC to have it included. */
 #if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
+#define SDL_ALTIVEC_INTRINSICS 1
 #include <altivec.h>
 #endif
 #if !defined(SDL_DISABLE_NEON)
 #  if defined(__ARM_NEON)
+#    define SDL_NEON_INTRINSICS 1
 #    include <arm_neon.h>
 #  elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
 /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
 #    if defined(_M_ARM)
+#      define SDL_NEON_INTRINSICS 1
 #      include <armintr.h>
 #      include <arm_neon.h>
 #      define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
 #    endif
 #    if defined (_M_ARM64)
+#      define SDL_NEON_INTRINSICS 1
 #      include <arm64intr.h>
 #      include <arm64_neon.h>
 #      define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */
@@ -108,27 +113,39 @@ _m_prefetch(void *__P)
 #endif
 
 #if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX)
-#include <lsxintrin.h>
+# define SDL_LSX_INTRINSICS 1
+# include <lsxintrin.h>
 #endif
+
 #if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX)
-#include <lasxintrin.h>
+# define SDL_LASX_INTRINSICS 1
+# include <lasxintrin.h>
 #endif
+
 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
-#if (defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX)
-#include <immintrin.h>
-#endif
-#if (defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
-#include <mmintrin.h>
-#endif
-#if (defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE)
-#include <xmmintrin.h>
-#endif
-#if (defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2)
-#include <emmintrin.h>
-#endif
-#if (defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3)
-#include <pmmintrin.h>
-#endif
-#endif /**/
+# if (defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX)
+#  define SDL_AVX_INTRINSICS
+#  include <immintrin.h>
+# endif
+# if (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(_M_IX86) && _M_IX86_FP == 1) || defined(_M_X64) || 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(_M_IX86) && _M_IX86_FP >= 1) || defined(_M_X64) || 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(_M_X64) || 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
+#endif /* defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) */
 
 #endif /* SDL_intrin_h_ */
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index 9e8487e2f69e..ca91f2346e72 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -186,47 +186,6 @@
 #include <SDL3/SDL.h>
 #include <SDL3/SDL_intrin.h>
 
-#if defined(__ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC)
-#define HAVE_ALTIVEC_INTRINSICS 1
-#endif
-
-#if defined(__ARM_NEON) && !defined(SDL_DISABLE_NEON)
-#define HAVE_NEON_INTRINSICS 1
-#endif
-
-#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
-
-#if (defined(__MMX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_MMX)
-#define HAVE_MMX_INTRINSICS 1
-#endif
-
-#if (defined(__SSE__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE)
-#define HAVE_SSE_INTRINSICS 1
-#endif
-
-#if (defined(__SSE2__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE2)
-#define HAVE_SSE2_INTRINSICS 1
-#endif
-
-#if (defined(__SSE3__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_SSE3)
-#define HAVE_SSE3_INTRINSICS 1
-#endif
-
-#if (defined(__AVX__) || defined(SDL_HAS_TARGET_ATTRIBS)) && !defined(SDL_DISABLE_AVX)
-#define HAVE_AVX_INTRINSICS 1
-#endif
-
-#endif /* x86/x64 */
-
-#if defined(__loongarch_sx) && !defined(SDL_DISABLE_LSX)
-#define HAVE_LSX_INTRINSICS 1
-#endif
-
-#if defined(__loongarch_asx) && !defined(SDL_DISABLE_LASX)
-#define HAVE_LASX_INTRINSICS 1
-#endif
-
-
 #define SDL_MAIN_NOIMPL /* don't drag in header-only implementation of SDL_main */
 #include <SDL3/SDL_main.h>
 
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 2eb74f8540c3..8c683678c40b 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -144,7 +144,7 @@ static int SDL_ConvertAudio(SDL_AudioCVT * cvt);
  * 8 channels (7.1) layout: FL+FR+FC+LFE+BL+BR+SL+SR
  */
 
-#if HAVE_SSE3_INTRINSICS
+#if SDL_SSE3_INTRINSICS
 /* Convert from stereo to mono. Average left and right. */
 static void SDLCALL SDL_TARGETING("sse3") SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
@@ -181,7 +181,7 @@ static void SDLCALL SDL_TARGETING("sse3") SDL_ConvertStereoToMono_SSE3(SDL_Audio
 }
 #endif
 
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
 /* Convert from mono to stereo. Duplicate to stereo left and right. */
 static void SDLCALL SDL_TARGETING("sse") SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
@@ -832,7 +832,7 @@ static int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
         /* swap in some SIMD versions for a few of these. */
         if (channel_converter == SDL_ConvertStereoToMono) {
             SDL_AudioFilter filter = NULL;
-#if HAVE_SSE3_INTRINSICS
+#if SDL_SSE3_INTRINSICS
             if (!filter && SDL_HasSSE3()) {
                 filter = SDL_ConvertStereoToMono_SSE3;
             }
@@ -842,7 +842,7 @@ static int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
             }
         } else if (channel_converter == SDL_ConvertMonoToStereo) {
             SDL_AudioFilter filter = NULL;
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
             if (!filter && SDL_HasSSE()) {
                 filter = SDL_ConvertMonoToStereo_SSE;
             }
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index e94a890dc413..7e83b52696b8 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -23,13 +23,13 @@
 #include "SDL_audio_c.h"
 #include "SDL_audiocvt_c.h"
 
-#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS
+#if defined(__x86_64__) && SDL_SSE2_INTRINSICS
 #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */
-#elif __MACOS__ && HAVE_SSE2_INTRINSICS
+#elif __MACOS__ && SDL_SSE2_INTRINSICS
 #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* macOS/Intel guarantees SSE2. */
-#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && HAVE_NEON_INTRINSICS
+#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && SDL_NEON_INTRINSICS
 #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* ARMv8+ promise NEON. */
-#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && HAVE_NEON_INTRINSICS
+#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && SDL_NEON_INTRINSICS
 #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* All Apple ARMv7 chips promise NEON support. */
 #endif
 
@@ -224,7 +224,7 @@ static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFo
 }
 #endif
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 static void SDLCALL SDL_TARGETING("sse2") SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1;
@@ -697,7 +697,7 @@ static void SDLCALL SDL_TARGETING("sse2") SDL_Convert_F32_to_S32_SSE2(SDL_AudioC
 }
 #endif
 
-#if HAVE_NEON_INTRINSICS
+#if SDL_NEON_INTRINSICS
 static void SDLCALL SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1;
@@ -1173,14 +1173,14 @@ void SDL_ChooseAudioConverters(void)
     SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \
     converters_chosen = SDL_TRUE
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
     if (SDL_HasSSE2()) {
         SET_CONVERTER_FUNCS(SSE2);
         return;
     }
 #endif
 
-#if HAVE_NEON_INTRINSICS
+#if SDL_NEON_INTRINSICS
     if (SDL_HasNEON()) {
         SET_CONVERTER_FUNCS(NEON);
         return;
diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c
index a9324a3ebf85..0de42ae42b6f 100644
--- a/src/video/SDL_blit_A.c
+++ b/src/video/SDL_blit_A.c
@@ -166,7 +166,7 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
     }
 }
 
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
 
 /* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
 static void SDL_TARGETING("mmx") BlitRGBtoRGBSurfaceAlpha128MMX(SDL_BlitInfo *info)
@@ -409,7 +409,7 @@ static void SDL_TARGETING("mmx") BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
     _mm_empty();
 }
 
-#endif /* HAVE_MMX_INTRINSICS */
+#endif /* SDL_MMX_INTRINSICS */
 
 #if SDL_ARM_SIMD_BLITTERS
 void BlitARGBto565PixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride);
@@ -750,7 +750,7 @@ static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
     }
 }
 
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
 
 /* fast RGB565->RGB565 blending with surface alpha */
 static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
@@ -1025,7 +1025,7 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info)
     }
 }
 
-#endif /* HAVE_MMX_INTRINSICS */
+#endif /* SDL_MMX_INTRINSICS */
 
 /* fast RGB565->RGB565 blending with surface alpha */
 static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
@@ -1357,13 +1357,13 @@ SDL_CalculateBlitA(SDL_Surface *surface)
 
         case 4:
             if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
                 if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
                     if (SDL_HasMMX()) {
                         return BlitRGBtoRGBPixelAlphaMMX;
                     }
                 }
-#endif /* HAVE_MMX_INTRINSICS */
+#endif /* SDL_MMX_INTRINSICS */
                 if (sf->Amask == 0xff000000) {
 #if SDL_ARM_NEON_BLITTERS
                     if (SDL_HasNEON()) {
@@ -1405,7 +1405,7 @@ SDL_CalculateBlitA(SDL_Surface *surface)
             case 2:
                 if (surface->map->identity) {
                     if (df->Gmask == 0x7e0) {
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
                         if (SDL_HasMMX()) {
                             return Blit565to565SurfaceAlphaMMX;
                         } else
@@ -1414,7 +1414,7 @@ SDL_CalculateBlitA(SDL_Surface *surface)
                             return Blit565to565SurfaceAlpha;
                         }
                     } else if (df->Gmask == 0x3e0) {
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
                         if (SDL_HasMMX()) {
                             return Blit555to555SurfaceAlphaMMX;
                         } else
@@ -1428,7 +1428,7 @@ SDL_CalculateBlitA(SDL_Surface *surface)
 
             case 4:
                 if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
                     if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && SDL_HasMMX()) {
                         return BlitRGBtoRGBSurfaceAlphaMMX;
                     }
diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c
index cc8cd22040c5..cfe67ccf78fc 100644
--- a/src/video/SDL_blit_copy.c
+++ b/src/video/SDL_blit_copy.c
@@ -23,7 +23,7 @@
 #include "SDL_blit.h"
 #include "SDL_blit_copy.h"
 
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
 /* This assumes 16-byte aligned src and dst */
 static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint8 *src, int len)
 {
@@ -48,9 +48,9 @@ static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint
         SDL_memcpy(dst, src, len & 63);
     }
 }
-#endif /* HAVE_SSE_INTRINSICS */
+#endif /* SDL_SSE_INTRINSICS */
 
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
 #ifdef _MSC_VER
 #pragma warning(disable : 4799)
 #endif
@@ -91,7 +91,7 @@ static SDL_INLINE void SDL_TARGETING("mmx") SDL_BlitCopyMMX(Uint8 *dst, const Ui
     }
     _mm_empty();
 }
-#endif /* HAVE_MMX_INTRINSICS */
+#endif /* SDL_MMX_INTRINSICS */
 
 void SDL_BlitCopy(SDL_BlitInfo *info)
 {
@@ -132,7 +132,7 @@ void SDL_BlitCopy(SDL_BlitInfo *info)
         return;
     }
 
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
     if (SDL_HasSSE() &&
         !((uintptr_t)src & 15) && !(srcskip & 15) &&
         !((uintptr_t)dst & 15) && !(dstskip & 15)) {
@@ -145,7 +145,7 @@ void SDL_BlitCopy(SDL_BlitInfo *info)
     }
 #endif
 
-#if HAVE_MMX_INTRINSICS
+#if SDL_MMX_INTRINSICS
     if (SDL_HasMMX() && !(srcskip & 7) && !(dstskip & 7)) {
         SDL_BlitCopyMMX(dst, src, w, h, dstskip, srcskip);
         return;
diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c
index 59c8128e9d01..e39e69e60979 100644
--- a/src/video/SDL_fillrect.c
+++ b/src/video/SDL_fillrect.c
@@ -22,7 +22,7 @@
 
 #include "SDL_blit.h"
 
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
 /* *INDENT-OFF* */ /* clang-format off */
 
 #if defined(_MSC_VER) && !defined(__clang__)
@@ -376,7 +376,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
         {
             color |= (color << 8);
             color |= (color << 16);
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
             if (SDL_HasSSE()) {
                 fill_function = SDL_FillSurfaceRect1SSE;
                 break;
@@ -389,7 +389,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
         case 2:
         {
             color |= (color << 16);
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
             if (SDL_HasSSE()) {
                 fill_function = SDL_FillSurfaceRect2SSE;
                 break;
@@ -408,7 +408,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
 
         case 4:
         {
-#if HAVE_SSE_INTRINSICS
+#if SDL_SSE_INTRINSICS
             if (SDL_HasSSE()) {
                 fill_function = SDL_FillSurfaceRect4SSE;
                 break;
diff --git a/src/video/SDL_stretch.c b/src/video/SDL_stretch.c
index 4b4091470443..bfcabfdea3e8 100644
--- a/src/video/SDL_stretch.c
+++ b/src/video/SDL_stretch.c
@@ -332,13 +332,13 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch,
     return 0;
 }
 
-#if HAVE_NEON_INTRINSICS
+#if SDL_NEON_INTRINSICS
 #define CAST_uint8x8_t       (uint8x8_t)
 #define CAST_uint32x2_t      (uint32x2_t)
 #endif
 
 #if defined(__WINRT__) || defined(_MSC_VER)
-#if HAVE_NEON_INTRINSICS
+#if SDL_NEON_INTRINSICS
 #undef CAST_uint8x8_t
 #undef CAST_uint32x2_t
 #define CAST_uint8x8_t
@@ -346,7 +346,7 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch,
 #endif
 #endif
 
-#if defined(HAVE_SSE2_INTRINSICS)
+#if defined(SDL_SSE2_INTRINSICS)
 
 #if 0
 static void SDL_TARGETING("sse2") printf_128(const char *str, __m128i var)
@@ -524,7 +524,7 @@ static int SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int
 }
 #endif
 
-#if defined(HAVE_NEON_INTRINSICS)
+#if defined(SDL_NEON_INTRINSICS)
 
 static SDL_INLINE int hasNEON(void)
 {
@@ -800,13 +800,13 @@ int SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect,
     Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * 4 + srcrect->y * src_pitch);
     Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * 4 + dstrect->y * dst_pitch);
 
-#if defined(HAVE_NEON_INTRINSICS)
+#if defined(SDL_NEON_INTRINSICS)
     if (ret == -1 && hasNEON()) {
         ret = scale_mat_NEON(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch);
     }
 #endif
 
-#if defined(HAVE_SSE2_INTRINSICS)
+#if defined(SDL_SSE2_INTRINSICS)
     if (ret == -1 && hasSSE2()) {
         ret = scale_mat_SSE(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch);
     }
diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c
index c5defcfc52b1..031d9a916a65 100644
--- a/src/video/SDL_yuv.c
+++ b/src/video/SDL_yuv.c
@@ -303,7 +303,7 @@ static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, i
     return 0;
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse(
     Uint32 src_format, Uint32 dst_format,
     Uint32 width, Uint32 height,
@@ -422,7 +422,7 @@ static SDL_bool yuv_rgb_sse(
 }
 #endif
 
-#if HAVE_LSX_INTRINSICS
+#if SDL_LSX_INTRINSICS
 static SDL_bool yuv_rgb_lsx(
     Uint32 src_format, Uint32 dst_format,
     Uint32 width, Uint32 height,
@@ -1122,7 +1122,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src
     return 0;
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
 {
     int x, y;
@@ -1192,7 +1192,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int w
 
 static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(width, height, src, src_pitch, dst, dst_pitch, reverseUV);
   } else
@@ -1251,7 +1251,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const voi
   }
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 static int SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
 {
     int x, y;
@@ -1326,7 +1326,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int
 
 static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(width, height, src, src_pitch, dst, dst_pitch, reverseUV);
   } else
@@ -1385,7 +1385,7 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const vo
   }
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 static int SDL_TARGETING("sse2") SDL_ConvertPixels_SwapNV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
     int x, y;
@@ -1429,7 +1429,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_SwapNV_SSE2(int width, int he
 
 static int SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_SwapNV_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1536,7 +1536,7 @@ static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height,
                         SDL_GetPixelFormatName(dst_format));
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 #define PACKED4_TO_PACKED4_ROW_SSE2(shuffle)                      \
     while (x >= 4) {                                              \
         __m128i yuv = _mm_loadu_si128((__m128i *)srcYUV);         \
@@ -1766,7 +1766,7 @@ static int SDL_TARGETING("sse2") SDL_ConvertPixels_YVYU_to_UYVY_SSE2(int width,
 
 static int SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_YUY2_to_UYVY_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1806,7 +1806,7 @@ static int SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src
 
 static int SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_YUY2_to_YVYU_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1846,7 +1846,7 @@ static int SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src
 
 static int SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_UYVY_to_YUY2_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1886,7 +1886,7 @@ static int SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src
 
 static int SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_UYVY_to_YVYU_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1926,7 +1926,7 @@ static int SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src
 
 static int SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_YVYU_to_YUY2_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
@@ -1966,7 +1966,7 @@ static int SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src
 
 static int SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
 {
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
   if (SDL_HasSSE2()) {
     return SDL_ConvertPixels_YVYU_to_UYVY_SSE2(width, height, src, src_pitch, dst, dst_pitch);
   } else
diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c
index 696e27282633..9455b6230dbd 100644
--- a/src/video/yuv2rgb/yuv_rgb.c
+++ b/src/video/yuv2rgb/yuv_rgb.c
@@ -239,7 +239,7 @@ void rgb24_yuv420_std(
 	}
 }
 
-#if HAVE_SSE2_INTRINSICS
+#if SDL_SSE2_INTRINSICS
 
 #define SSE_FUNCTION_NAME	yuv420_rgb565_sse
 #define STD_FUNCTION_NAME	yuv420_rgb565_std
@@ -682,9 +682,9 @@ void SDL_TARGETING("sse2") rgb24_yuv420_sseu(uint32_t width, uint32_t height,
 }
 
 
-#endif //HAVE_SSE2_INTRINSICS
+#endif //SDL_SSE2_INTRINSICS
 
-#if HAVE_LSX_INTRINSICS
+#if SDL_LSX_INTRINSICS
 
 #define LSX_FUNCTION_NAME	yuv420_rgb24_lsx
 #define STD_FUNCTION_NAME	yuv420_rgb24_std
@@ -716,6 +716,6 @@ void SDL_TARGETING("sse2") rgb24_yuv420_sseu(uint32_t width, uint32_t height,
 #define RGB_FORMAT			RGB_FORMAT_ABGR
 #include "yuv_rgb_lsx_func.h"
 
-#endif  //HAVE_LSX_INTRINSICS
+#endif  //SDL_LSX_INTRINSICS
 
 #endif /* SDL_HAVE_YUV */