Add Altivec detection for PowerMac

We now need to detect Altivec/Power4. Formerly it did not matter so CPU_QueryAltivec simply returned false
pull/548/head
Jeffrey Walton 2017-12-13 11:49:35 -05:00
parent e1c9746b70
commit 43a34590a9
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 13 additions and 1 deletions

14
cpu.cpp
View File

@ -33,7 +33,7 @@
unsigned long int getauxval(unsigned long int) { return 0; } unsigned long int getauxval(unsigned long int) { return 0; }
#endif #endif
#if defined(__APPLE__) && defined(__aarch64__) #if defined(__APPLE__) && (defined(__aarch64__) || defined(__POWERPC__))
# include <sys/utsname.h> # include <sys/utsname.h>
#endif #endif
@ -596,6 +596,18 @@ inline bool CPU_QueryAltivec()
#if defined(__linux__) #if defined(__linux__)
if (getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC) if (getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC)
return true; return true;
#elif defined(__APPLE__) && defined(__POWERPC__)
// http://stackoverflow.com/questions/45637888/how-to-determine-armv8-features-at-runtime-on-ios
struct utsname systemInfo;
systemInfo.machine[0] = '\0';
uname(&systemInfo);
// The machine strings below are known PPC machines
std::string machine(systemInfo.machine);
if (machine.substr(0, 15) == "Power Macintosh")
{
return true;
}
#endif #endif
return false; return false;
} }