mirror of https://github.com/encounter/SDL.git
Fix AltiVec detection on FreeBSD
The previous code was not correct, because there's no PPC_FEATURE_HAS_ALTIVEC MIB. Instead, elf vector check should be done.
This commit is contained in:
parent
c45facf2ca
commit
9886d897e2
|
@ -50,10 +50,13 @@
|
||||||
#endif
|
#endif
|
||||||
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
|
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
|
||||||
#include <sys/sysctl.h> /* For AltiVec check */
|
#include <sys/sysctl.h> /* For AltiVec check */
|
||||||
#elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
|
#elif defined(__OpenBSD__) && defined(__powerpc__)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/sysctl.h> /* For AltiVec check */
|
#include <sys/sysctl.h> /* For AltiVec check */
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
|
#elif defined(__FreeBSD__) && defined(__powerpc__)
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#include <sys/auxv.h>
|
||||||
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
@ -110,7 +113,7 @@
|
||||||
#define CPU_HAS_AVX512F (1 << 12)
|
#define CPU_HAS_AVX512F (1 << 12)
|
||||||
#define CPU_HAS_ARM_SIMD (1 << 13)
|
#define CPU_HAS_ARM_SIMD (1 << 13)
|
||||||
|
|
||||||
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__
|
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ && !__FreeBSD__
|
||||||
/* 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!
|
||||||
*/
|
*/
|
||||||
|
@ -314,11 +317,9 @@ CPU_haveAltiVec(void)
|
||||||
{
|
{
|
||||||
volatile int altivec = 0;
|
volatile int altivec = 0;
|
||||||
#ifndef SDL_CPUINFO_DISABLED
|
#ifndef SDL_CPUINFO_DISABLED
|
||||||
#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__)) || (defined(__FreeBSD__) && defined(__powerpc__))
|
#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
|
int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
int selectors[2] = { CTL_HW, PPC_FEATURE_HAS_ALTIVEC };
|
|
||||||
#else
|
#else
|
||||||
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
|
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
|
||||||
#endif
|
#endif
|
||||||
|
@ -327,6 +328,11 @@ CPU_haveAltiVec(void)
|
||||||
int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
|
int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
|
||||||
if (0 == error)
|
if (0 == error)
|
||||||
altivec = (hasVectorUnit != 0);
|
altivec = (hasVectorUnit != 0);
|
||||||
|
#elif defined(__FreeBSD__) && defined(__powerpc__)
|
||||||
|
unsigned long cpufeatures = 0;
|
||||||
|
elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
|
||||||
|
altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
|
||||||
|
return altivec;
|
||||||
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
||||||
void (*handler) (int sig);
|
void (*handler) (int sig);
|
||||||
handler = signal(SIGILL, illegal_instruction);
|
handler = signal(SIGILL, illegal_instruction);
|
||||||
|
|
Loading…
Reference in New Issue