Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -182,8 +182,19 @@ * * @return Whether the CPU supports AVX2 */ + (bool)supportsAVX2; #endif + +#if defined(OF_POWERPC) || defined(OF_POWERPC64) +/*! + * @brief Returns whether the CPU and OS support AltiVec. + * + * @note This method is only available on PowerPC and PowerPC64. + * + * @return Whether the CPU and OS support AltiVec + */ ++ (bool)supportsAltiVec; +#endif @end OF_ASSUME_NONNULL_END Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -23,10 +23,16 @@ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include + +#include "platform.h" + +#ifdef OF_MAC_OS_X +# include +#endif #import "OFSystemInfo.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" @@ -365,6 +371,21 @@ + (bool)supportsAVX2 { return x86_cpuid(0, 0).eax >= 7 && (x86_cpuid(7, 0).ebx & (1 << 5)); } #endif + +#if defined(OF_POWERPC) || defined(OF_POWERPC64) ++ (bool)supportsAltiVec +{ +# ifdef OF_MAC_OS_X + int name[2] = { CTL_HW, HW_VECTORUNIT }, value = 0; + size_t length = sizeof(value); + + if (sysctl(name, 2, &value, &length, NULL, 0) == 0) + return value; +# endif + + return 0; +} +#endif @end