CPU (Linux): only try lscpu on Linux

Since `lscpu` is a program of `util-linux`
This commit is contained in:
李通洲
2023-09-27 15:11:05 +08:00
parent 7caa8d4618
commit 767f99cffa
+12 -10
View File
@@ -51,16 +51,6 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
);
}
if (cpu->name.length == 0)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
{
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
}
}
return NULL;
}
@@ -174,5 +164,17 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
detectAndroid(cpu);
#endif
#ifdef __linux__
if (cpu->name.length == 0)
{
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
{
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
}
}
#endif
return NULL;
}