CPU (X86): adds code name and tech detection

Fixes #1501
This commit is contained in:
李通洲
2026-06-07 10:46:37 +08:00
parent c706201282
commit e936ddef6b
5 changed files with 1439 additions and 0 deletions
+1
View File
@@ -447,6 +447,7 @@ set(LIBFASTFETCH_SRC
src/detection/codec/codec.c
src/detection/codec/codec_vulkan.c
src/detection/cpu/cpu.c
src/detection/cpu/cpu_x86.c
src/detection/cpuusage/cpuusage.c
src/detection/command/command.c
src/detection/disk/disk.c
+5
View File
@@ -22,6 +22,11 @@ const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu) {
ffStrbufSubstrBeforeFirstC(&cpu->name, '@'); // Cut the speed output in the name as we append our own
ffStrbufTrimRight(&cpu->name, ' '); // If we removed the @ in previous step there was most likely a space before it
ffStrbufRemoveDupWhitespaces(&cpu->name);
#if __i386__ || __x86_64__
ffCPUDetectX86Specific(cpu);
#endif
return NULL;
}
+11
View File
@@ -27,9 +27,20 @@ typedef struct FFCPUResult {
FFCPUCore coreTypes[16]; // number of P cores, E cores, etc.
double temperature;
#if __i386__ || __x86_64__
const char* codeName;
const char* technology;
#endif
} FFCPUResult;
const char* ffDetectCPU(const FFCPUOptions* options, FFCPUResult* cpu);
const char* ffCPUAppleCodeToName(uint32_t code);
const char* ffCPUQualcommCodeToName(uint32_t code);
void ffCPUDetectByCpuid(FFCPUResult* cpu);
#if __i386__ || __x86_64__
bool ffCPUDetectX86Specific(FFCPUResult* cpu);
#endif
File diff suppressed because it is too large Load Diff
+22
View File
@@ -102,6 +102,10 @@ bool ffPrintCPU(FFCPUOptions* options) {
FF_ARG(cpu.packages, "packages"),
FF_ARG(cpu.march, "march"),
FF_ARG(cpu.numaNodes, "numa-nodes"),
#if __i386__ || __x86_64__
FF_ARG(cpu.codeName, "code-name"),
FF_ARG(cpu.technology, "technology"),
#endif
}));
}
success = true;
@@ -214,6 +218,20 @@ bool ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
yyjson_mut_obj_add_null(doc, obj, "numaNodes");
}
#if __i386__ || __x86_64__
if (cpu.codeName) {
yyjson_mut_obj_add_str(doc, obj, "codeName", cpu.codeName);
} else {
yyjson_mut_obj_add_null(doc, obj, "codeName");
}
if (cpu.technology) {
yyjson_mut_obj_add_str(doc, obj, "technology", cpu.technology);
} else {
yyjson_mut_obj_add_null(doc, obj, "technology");
}
#endif
success = true;
}
@@ -258,5 +276,9 @@ FFModuleBaseInfo ffCPUModuleInfo = {
{ "Processor package count", "packages" },
{ "CPU microarchitecture", "march" },
{ "NUMA node count", "numa-nodes" },
#if __i386__ || __x86_64__
{ "CPU code name", "code-name" },
{ "CPU technology", "technology" },
#endif
}))
};