CPU (macOS): fix compiling

This commit is contained in:
李通洲
2024-05-18 18:22:32 +08:00
committed by Carter Li
parent 7946e69a66
commit d88e2eeb36
2 changed files with 8 additions and 6 deletions
+7 -5
View File
@@ -82,17 +82,19 @@ static const char* detectFrequency(FFCPUResult* cpu)
static const char* detectCoreCount(FFCPUResult* cpu)
{
int nPerfLevels = ffSysctlGetInt("hw.nperflevels", 0);
uint32_t nPerfLevels = (uint32_t) ffSysctlGetInt("hw.nperflevels", 0);
if (nPerfLevels <= 0) return "sysctl(hw.nperflevels) failed";
char sysctlKey[] = "hw.perflevelN.logicalcpu";
for (int i = 0; i < nPerfLevels; ++i)
if (nPerfLevels > sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]))
nPerfLevels = sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]);
for (uint32_t i = 0; i < nPerfLevels; ++i)
{
sysctlKey[strlen("hw.perflevel")] = (char) ('0' + i);
cpu->coreTypes[i < (int) sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]) : i : (int) sizeof(cpu->coreTypes) / sizeof(cpu->coreTypes[0]) - 1] = {
cpu->coreTypes[i] = (FFCPUCore) {
.freq = nPerfLevels - i,
.count = ffSysctlGetInt(sysctlKey, 0),
}
.count = (uint32_t) ffSysctlGetInt(sysctlKey, 0),
};
}
return NULL;
}