Skip to content

Commit 7ee0e87

Browse files
committed
CPU (macOS): use CPUID for freq detection on Intel
1 parent a734713 commit 7ee0e87

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/detection/cpu/cpu_apple.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ static const char* detectFrequency(FFCPUResult* cpu)
7272
#else
7373
static const char* detectFrequency(FFCPUResult* cpu)
7474
{
75-
cpu->frequencyBase = (uint32_t) (ffSysctlGetInt64("hw.cpufrequency", 0) / 1000 / 1000);
76-
cpu->frequencyMax = (uint32_t) (ffSysctlGetInt64("hw.cpufrequency_max", 0) / 1000 / 1000);
77-
if(cpu->frequencyBase == 0)
75+
if (ffCPUDetectSpeedByCpuid(cpu) != NULL)
7876
{
79-
unsigned current = 0;
80-
size_t size = sizeof(current);
81-
if (sysctl((int[]){ CTL_HW, HW_CPU_FREQ }, 2, &current, &size, NULL, 0) == 0)
82-
cpu->frequencyBase = (uint32_t) (current / 1000 / 1000);
77+
cpu->frequencyBase = (uint32_t) (ffSysctlGetInt64("hw.cpufrequency", 0) / 1000 / 1000);
78+
cpu->frequencyMax = (uint32_t) (ffSysctlGetInt64("hw.cpufrequency_max", 0) / 1000 / 1000);
79+
if(cpu->frequencyBase == 0)
80+
{
81+
unsigned current = 0;
82+
size_t size = sizeof(current);
83+
if (sysctl((int[]){ CTL_HW, HW_CPU_FREQ }, 2, &current, &size, NULL, 0) == 0)
84+
cpu->frequencyBase = (uint32_t) (current / 1000 / 1000);
85+
}
8386
}
8487
return NULL;
8588
}

0 commit comments

Comments
 (0)