mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
@@ -15,7 +15,7 @@ typedef struct FFCPUResult
|
||||
FFstrbuf name;
|
||||
FFstrbuf vendor;
|
||||
|
||||
uint16_t cpuCount;
|
||||
uint16_t packages;
|
||||
uint16_t coresPhysical;
|
||||
uint16_t coresLogical;
|
||||
uint16_t coresOnline;
|
||||
|
||||
@@ -109,7 +109,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
return "sysctlbyname(machdep.cpu.brand_string) failed";
|
||||
|
||||
ffSysctlGetString("machdep.cpu.vendor", &cpu->vendor);
|
||||
cpu->cpuCount = (uint16_t) ffSysctlGetInt("hw.packages", 1);
|
||||
cpu->packages = (uint16_t) ffSysctlGetInt("hw.packages", 1);
|
||||
if (cpu->vendor.length == 0 && ffStrbufStartsWithS(&cpu->name, "Apple "))
|
||||
ffStrbufAppendS(&cpu->vendor, "Apple");
|
||||
|
||||
|
||||
@@ -464,7 +464,7 @@ FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu)
|
||||
}
|
||||
}
|
||||
|
||||
FF_MAYBE_UNUSED static uint16_t getCPUCount(FFstrbuf* cpuinfo)
|
||||
FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo)
|
||||
{
|
||||
const char* p = cpuinfo->chars;
|
||||
uint64_t bits = 0;
|
||||
@@ -502,7 +502,9 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
|
||||
cpu->coresLogical = (uint16_t) get_nprocs_conf();
|
||||
cpu->coresOnline = (uint16_t) get_nprocs();
|
||||
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);
|
||||
cpu->cpuCount = getCPUCount(&cpuinfo);
|
||||
#if __x86_64__ || __i386__
|
||||
cpu->packages = getPackageCount(&cpuinfo);
|
||||
#endif
|
||||
|
||||
// Ref https://github.com/fastfetch-cli/fastfetch/issues/1194#issuecomment-2295058252
|
||||
ffCPUDetectSpeedByCpuid(cpu);
|
||||
|
||||
@@ -112,7 +112,7 @@ static const char* detectNCores(FFCPUResult* cpu)
|
||||
}
|
||||
|
||||
if (ptr->Relationship == RelationProcessorPackage) {
|
||||
cpu->cpuCount++;
|
||||
cpu->packages++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -6,7 +6,7 @@
|
||||
#include "modules/cpu/cpu.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 9
|
||||
#define FF_CPU_NUM_FORMAT_ARGS 10
|
||||
|
||||
static int sortCores(const FFCPUCore* a, const FFCPUCore* b)
|
||||
{
|
||||
@@ -55,8 +55,8 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
|
||||
|
||||
if(cpu.cpuCount > 1)
|
||||
ffStrbufAppendF(&str, "%u x ", cpu.cpuCount);
|
||||
if(cpu.packages > 1)
|
||||
ffStrbufAppendF(&str, "%u x ", cpu.packages);
|
||||
|
||||
if(cpu.name.length > 0)
|
||||
ffStrbufAppend(&str, &cpu.name);
|
||||
@@ -72,7 +72,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
ffStrbufAppendF(&str, " (%s)", coreTypes.chars);
|
||||
else if(cpu.coresOnline > 1)
|
||||
{
|
||||
if(cpu.cpuCount > 1)
|
||||
if(cpu.packages > 1)
|
||||
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline / 2);
|
||||
else
|
||||
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
|
||||
@@ -114,6 +114,7 @@ void ffPrintCPU(FFCPUOptions* options)
|
||||
FF_FORMAT_ARG(freqMax, "freq-max"),
|
||||
FF_FORMAT_ARG(tempStr, "temperature"),
|
||||
FF_FORMAT_ARG(coreTypes, "core-types"),
|
||||
FF_FORMAT_ARG(cpu.packages, "packages"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -211,6 +212,10 @@ void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
|
||||
yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result");
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "cpu", &cpu.name);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &cpu.vendor);
|
||||
if (cpu.packages == 0)
|
||||
yyjson_mut_obj_add_null(doc, obj, "packages");
|
||||
else
|
||||
yyjson_mut_obj_add_uint(doc, obj, "packages", cpu.packages);
|
||||
|
||||
yyjson_mut_val* cores = yyjson_mut_obj_add_obj(doc, obj, "cores");
|
||||
yyjson_mut_obj_add_uint(doc, cores, "physical", cpu.coresPhysical);
|
||||
@@ -248,6 +253,7 @@ void ffPrintCPUHelpFormat(void)
|
||||
"Max frequency (formatted) - freq-max",
|
||||
"Temperature (formatted) - temperature",
|
||||
"Logical core count grouped by frequency - core-types",
|
||||
"Processor package count - packages",
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user