Skip to content

Commit

Permalink
Added: linux implementation for cpu caps runtime detection, thanks Al…
Browse files Browse the repository at this point in the history
…TheKiller
  • Loading branch information
CrystalP authored and CrystalP committed Jan 29, 2011
1 parent 529b3e9 commit 78efd6f
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion xbmc/utils/CPUInfo.cpp
Expand Up @@ -120,6 +120,9 @@ CCPUInfo::CCPUInfo(void)
core.m_id = i;
m_cores[core.m_id] = core;
}

ReadCPUFeatures();

#elif defined(_WIN32)
char rgValue [128];
HKEY hKey;
Expand All @@ -140,6 +143,9 @@ CCPUInfo::CCPUInfo(void)

CoreInfo core;
m_cores[0] = core;

ReadCPUFeatures();

#else
m_fProcStat = fopen("/proc/stat", "r");
m_fProcTemperature = fopen("/proc/acpi/thermal_zone/THM0/temperature", "r");
Expand Down Expand Up @@ -192,6 +198,39 @@ CCPUInfo::CCPUInfo(void)
m_cores[nCurrId].m_strModel.Trim();
}
}
else if (strncmp(buffer, "flags", 5) == 0)
{
char* needle = strchr(buffer, ':');
if (needle)
{
char* tok = NULL,
* save;
needle++;
tok = strtok_r(needle, " ", &save);
while (tok)
{
if (0 == strcmp(tok, "mmx"))
m_cpuFeatures |= CPU_FEATURE_MMX;
else if (0 == strcmp(tok, "mmxext"))
m_cpuFeatures |= CPU_FEATURE_MMX2;
else if (0 == strcmp(tok, "sse"))
m_cpuFeatures |= CPU_FEATURE_SSE;
else if (0 == strcmp(tok, "sse2"))
m_cpuFeatures |= CPU_FEATURE_SSE2;
else if (0 == strcmp(tok, "ssse3"))
m_cpuFeatures |= CPU_FEATURE_SSE3;
else if (0 == strcmp(tok, "sse4_1"))
m_cpuFeatures |= CPU_FEATURE_SSE4;
else if (0 == strcmp(tok, "sse4_2"))
m_cpuFeatures |= CPU_FEATURE_SSE42;
else if (0 == strcmp(tok, "3dnow"))
m_cpuFeatures |= CPU_FEATURE_3DNOW;
else if (0 == strcmp(tok, "3dnowext"))
m_cpuFeatures |= CPU_FEATURE_3DNOWEXT;
tok = strtok_r(NULL, " ", &save);
}
}
}
}
}
else
Expand All @@ -202,7 +241,6 @@ CCPUInfo::CCPUInfo(void)

readProcStat(m_userTicks, m_niceTicks, m_systemTicks, m_idleTicks, m_ioTicks);
#endif
ReadCPUFeatures();
}

CCPUInfo::~CCPUInfo()
Expand Down

0 comments on commit 78efd6f

Please sign in to comment.