Skip to content

Commit 767f99c

Browse files
committed
CPU (Linux): only try lscpu on Linux
Since `lscpu` is a program of `util-linux`
1 parent 7caa8d4 commit 767f99c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/detection/cpu/cpu_linux.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ static const char* parseCpuInfo(FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer,
5151
);
5252
}
5353

54-
if (cpu->name.length == 0)
55-
{
56-
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
57-
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
58-
{
59-
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
60-
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
61-
}
62-
}
63-
6454
return NULL;
6555
}
6656

@@ -174,5 +164,17 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
174164
detectAndroid(cpu);
175165
#endif
176166

167+
#ifdef __linux__
168+
if (cpu->name.length == 0)
169+
{
170+
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
171+
if (!ffProcessAppendStdOut(&buffer, (char *const[]) { "lscpu", NULL }))
172+
{
173+
ffParsePropLines(buffer.chars, "Model name:", &cpu->name);
174+
if (ffStrbufEqualS(&cpu->name, "-")) ffStrbufClear(&cpu->name);
175+
}
176+
}
177+
#endif
178+
177179
return NULL;
178180
}

0 commit comments

Comments
 (0)