summaryrefslogtreecommitdiff
path: root/user/sdl2/altivec-detection.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/sdl2/altivec-detection.patch')
-rw-r--r--user/sdl2/altivec-detection.patch22
1 files changed, 22 insertions, 0 deletions
diff --git a/user/sdl2/altivec-detection.patch b/user/sdl2/altivec-detection.patch
new file mode 100644
index 000000000..ccb60a375
--- /dev/null
+++ b/user/sdl2/altivec-detection.patch
@@ -0,0 +1,22 @@
+Use getauxval on Linux if available.
+
+--- SDL2-2.0.22/src/cpuinfo/SDL_cpuinfo.c.old 2022-01-08 02:29:52.000000000 +0000
++++ SDL2-2.0.22/src/cpuinfo/SDL_cpuinfo.c 2025-04-27 18:58:12.097867624 +0000
+@@ -113,7 +113,7 @@
+ #define CPU_HAS_AVX512F (1 << 12)
+ #define CPU_HAS_ARM_SIMD (1 << 13)
+
+-#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ && !__FreeBSD__
++#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ && !__FreeBSD__ && !__linux__
+ /* This is the brute force way of detecting instruction sets...
+ the idea is borrowed from the libmpeg2 library - thanks!
+ */
+@@ -333,6 +333,8 @@
+ elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
+ altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
+ return altivec;
++#elif defined(__linux__) && defined(__powerpc__) && HAVE_GETAUXVAL
++ altivec = getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC;
+ #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
+ void (*handler) (int sig);
+ handler = signal(SIGILL, illegal_instruction);