Skip to content

Commit 591dba8

Browse files
committed
CPU (Linux): don't parse unnecessary lines on certain platforms
1 parent d10dd20 commit 591dba8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/detection/cpu/cpu_linux.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ static void detectArmName(FILE* cpuinfo, FFCPUResult* cpu, uint32_t implId)
137137
}
138138
#endif
139139

140-
static const char* parseCpuInfo(FILE* cpuinfo, FFCPUResult* cpu, FFstrbuf* physicalCoresBuffer, FFstrbuf* cpuMHz, FFstrbuf* cpuIsa, FFstrbuf* cpuUarch, FF_MAYBE_UNUSED FFstrbuf* cpuImplementer)
140+
static const char* parseCpuInfo(
141+
FILE* cpuinfo,
142+
FFCPUResult* cpu,
143+
FFstrbuf* physicalCoresBuffer,
144+
FFstrbuf* cpuMHz,
145+
FF_MAYBE_UNUSED FFstrbuf* cpuIsa,
146+
FF_MAYBE_UNUSED FFstrbuf* cpuUarch,
147+
FF_MAYBE_UNUSED FFstrbuf* cpuImplementer)
141148
{
142149
FF_AUTO_FREE char* line = NULL;
143150
size_t len = 0;
@@ -157,8 +164,11 @@ static const char* parseCpuInfo(FILE* cpuinfo, FFCPUResult* cpu, FFstrbuf* physi
157164
ffParsePropLine(line, "vendor_id :", &cpu->vendor) ||
158165
ffParsePropLine(line, "cpu cores :", physicalCoresBuffer) ||
159166
ffParsePropLine(line, "cpu MHz :", cpuMHz) ||
167+
168+
#if !(__x86_64__ || __i386__ || __arm__ || __aarch64__)
160169
ffParsePropLine(line, "isa :", cpuIsa) ||
161170
ffParsePropLine(line, "uarch :", cpuUarch) ||
171+
#endif
162172

163173
#if __arm__ || __aarch64__
164174
(cpuImplementer->length == 0 && ffParsePropLine(line, "CPU implementer :", cpuImplementer)) ||
@@ -277,7 +287,7 @@ static double detectCPUTemp(void)
277287
return FF_CPU_TEMP_UNSET;
278288
}
279289

280-
static void parseIsa(FFstrbuf* cpuIsa)
290+
FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa)
281291
{
282292
if(ffStrbufStartsWithS(cpuIsa, "rv"))
283293
{
@@ -300,7 +310,7 @@ static void parseIsa(FFstrbuf* cpuIsa)
300310
}
301311
}
302312

303-
void detectAsahi(FFCPUResult* cpu)
313+
FF_MAYBE_UNUSED static void detectAsahi(FFCPUResult* cpu)
304314
{
305315
// In Asahi Linux, reading /proc/device-tree/compatible gives
306316
// information on the device model. It consists of 3 NUL terminated
@@ -349,6 +359,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
349359
if (!detectFrequency(cpu, options) || cpu->frequencyBase == 0)
350360
cpu->frequencyBase = (uint32_t) ffStrbufToUInt(&cpuMHz, 0);
351361

362+
#if !(__x86_64__ || __i386__ || __arm__ || __aarch64__)
352363
if(cpuUarch.length > 0)
353364
{
354365
if(cpu->name.length > 0)
@@ -363,6 +374,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
363374
ffStrbufAppendC(&cpu->name, ' ');
364375
ffStrbufAppend(&cpu->name, &cpuIsa);
365376
}
377+
#endif
366378

367379
#if __arm__ || __aarch64__
368380
uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, NULL, 16);

0 commit comments

Comments
 (0)