mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
CPU (macOS): fix compiling
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
{
|
||||
FF_STRBUF_AUTO_DESTROY coreTypes = ffStrbufCreate();
|
||||
uint32_t typeCount = 0;
|
||||
while (cpu.coreTypes[typeCount].count != 0) typeCount++;
|
||||
while (cpu.coreTypes[typeCount].count != 0 && typeCount < sizeof(cpu.coreTypes) / sizeof(cpu.coreTypes[0])) typeCount++;
|
||||
if (typeCount > 0)
|
||||
{
|
||||
qsort(cpu.coreTypes, typeCount, sizeof(cpu.coreTypes[0]), (void*) sortCores);
|
||||
|
||||
Reference in New Issue
Block a user