32 #include <QStringList> 35 #if defined (Q_PROCESSOR_X86) 52 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
53 if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
54 qWarning () << Q_FUNC_INFO
55 <<
"failed to get CPUID eax = 1";
59 if (__get_cpuid_max (0,
nullptr) < 7)
60 qWarning () << Q_FUNC_INFO
61 <<
"cpuid max less than 7";
64 __cpuid_count (7, 0, eax, ebx, ecx, edx);
69 static std::once_flag dbgFlag;
70 std::call_once (dbgFlag,
71 [
this] { DumpDetectedFeatures (); });
100 return Ecx1_ & (1 << 9);
102 return Ecx1_ & (1 << 19);
104 return Ecx1_ & (1 << 28);
106 return Ecx1_ & (1 << 26);
116 void CpuFeatures::DumpDetectedFeatures ()
const 118 if (qgetenv (
"DUMP_CPUFEATURES").isEmpty ())
121 QStringList detected;
122 QStringList undetected;
126 const auto feature =
static_cast<Feature> (i);
129 detected << featureName;
131 undetected << featureName;
134 qDebug () << Q_FUNC_INFO;
135 qDebug () <<
"detected the following CPU features:" << detected.join (
" ").toUtf8 ().constData ();
136 qDebug () <<
"couldn't detect the following CPU features:" << undetected.join (
" ").toUtf8 ().constData ();
bool HasFeature(Feature) const
static QString GetFeatureName(Feature)