aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-08-15 06:28:45 -0700
committerChris Robinson <[email protected]>2012-08-15 06:28:45 -0700
commitf4ff63e2715b28e8ed1fd54e48e3ee6077f1689d (patch)
treee7939b0157ea4c56774ab50410c7ba0439946346
parentbbcf4e8c1d76948a901c4ab3e919d3c99c2e2459 (diff)
Check the max CPUID functions before calling them
-rw-r--r--Alc/helpers.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 26a32b69..bf83bcbf 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -80,15 +80,22 @@ void FillCPUCaps(ALuint capfilter)
ERR("Failed to get CPUID\n");
else
{
+ unsigned int maxfunc = cpuinf[0].regs[0];
+ unsigned int maxextfunc = 0;
+
+ if(__get_cpuid(0x80000000, &cpuinf[0].regs[0], &cpuinf[0].regs[1], &cpuinf[0].regs[2], &cpuinf[0].regs[3]))
+ maxextfunc = cpuinf[0].regs[0];
+ TRACE("Detected max CPUID function: 0x%x (ext. 0x%x)\n", maxfunc, maxextfunc);
+
TRACE("Vendor ID: \"%.4s%.4s%.4s\"\n", cpuinf[0].str+4, cpuinf[0].str+12, cpuinf[0].str+8);
- if(__get_cpuid(0x80000002, &cpuinf[0].regs[0], &cpuinf[0].regs[1], &cpuinf[0].regs[2], &cpuinf[0].regs[3]) &&
+ if(maxextfunc >= 0x80000004 &&
+ __get_cpuid(0x80000002, &cpuinf[0].regs[0], &cpuinf[0].regs[1], &cpuinf[0].regs[2], &cpuinf[0].regs[3]) &&
__get_cpuid(0x80000003, &cpuinf[1].regs[0], &cpuinf[1].regs[1], &cpuinf[1].regs[2], &cpuinf[1].regs[3]) &&
__get_cpuid(0x80000004, &cpuinf[2].regs[0], &cpuinf[2].regs[1], &cpuinf[2].regs[2], &cpuinf[2].regs[3]))
TRACE("Name: \"%.16s%.16s%.16s\"\n", cpuinf[0].str, cpuinf[1].str, cpuinf[2].str);
- if(!__get_cpuid(1, &cpuinf[0].regs[0], &cpuinf[0].regs[1], &cpuinf[0].regs[2], &cpuinf[0].regs[3]))
- ERR("Failed to get CPU features\n");
- else
+ if(maxfunc >= 1 &&
+ __get_cpuid(1, &cpuinf[0].regs[0], &cpuinf[0].regs[1], &cpuinf[0].regs[2], &cpuinf[0].regs[3]))
{
#ifdef bit_SSE
if((cpuinf[0].regs[3]&bit_SSE))