فهرست منبع

cpuinfo: Use auxv for AltiVec on Linux if possible

The SIGILL handler is not very reliable and can cause crashes.

Linux provides the CPU's AltiVec support status in getauxval.
A. Wilcox 10 ماه پیش
والد
کامیت
7490471796
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      src/cpuinfo/SDL_cpuinfo.c

+ 3 - 1
src/cpuinfo/SDL_cpuinfo.c

@@ -115,7 +115,7 @@
 #define CPU_CFG2_LSX  (1 << 6)
 #define CPU_CFG2_LSX  (1 << 6)
 #define CPU_CFG2_LASX (1 << 7)
 #define CPU_CFG2_LASX (1 << 7)
 
 
-#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(SDL_PLATFORM_MACOS) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_FREEBSD)
+#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(SDL_PLATFORM_MACOS) && !defined(SDL_PLATFORM_OPENBSD) && !defined(SDL_PLATFORM_FREEBSD) && (defined(SDL_PLATFORM_LINUX) && !defined(HAVE_GETAUXVAL))
 /* This is the brute force way of detecting instruction sets...
 /* This is the brute force way of detecting instruction sets...
    the idea is borrowed from the libmpeg2 library - thanks!
    the idea is borrowed from the libmpeg2 library - thanks!
  */
  */
@@ -344,6 +344,8 @@ static int CPU_haveAltiVec(void)
     elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
     elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
     altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
     altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
     return altivec;
     return altivec;
+#elif defined(SDL_PLATFORM_LINUX) && defined(__powerpc__) && defined(HAVE_GETAUXVAL)
+    altivec = getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC;
 #elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
 #elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
     void (*handler)(int sig);
     void (*handler)(int sig);
     handler = signal(SIGILL, illegal_instruction);
     handler = signal(SIGILL, illegal_instruction);