From 35d431dd3f2d293ba8c87572738d9744733e051a Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 22 Jan 2025 22:19:23 +0800 Subject: [PATCH] CPU (Linux): detect SOC name on RISCV Fix #1519 --- src/detection/cpu/cpu_linux.c | 45 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index f687791f3..d0b4bd840 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -432,7 +432,7 @@ FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa) } } -FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu) +FF_MAYBE_UNUSED static void detectSocName(FFCPUResult* cpu) { if (cpu->name.length > 0) return; @@ -565,35 +565,36 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) if (!detectFrequency(cpu, options) || cpu->frequencyBase == 0) cpu->frequencyBase = (uint32_t) ffStrbufToUInt(&cpuMHz, 0); - #if !(__x86_64__ || __i386__ || __arm__ || __aarch64__) - if(cpuUarch.length > 0) - { - if(cpu->name.length > 0) - ffStrbufAppendC(&cpu->name, ' '); - ffStrbufAppend(&cpu->name, &cpuUarch); - } - - if(cpuIsa.length > 0) - { - parseIsa(&cpuIsa); - if(cpu->name.length > 0) - ffStrbufAppendC(&cpu->name, ' '); - ffStrbufAppend(&cpu->name, &cpuIsa); - } + #if __ANDROID__ + detectAndroid(cpu); + #elif !(__x86_64__ || __i386__) + detectSocName(cpu); #endif #if __arm__ || __aarch64__ uint32_t cpuImplementer = (uint32_t) strtoul(cpuImplementerStr.chars, NULL, 16); ffStrbufSetStatic(&cpu->vendor, hwImplId2Vendor(cpuImplementer)); - #if __ANDROID__ - detectAndroid(cpu); - #else - detectArmSoc(cpu); - #endif - if (cpu->name.length == 0) detectArmName(&cpuinfo, cpu, cpuImplementer); + #elif !(__x86_64__ || __i386__) + if (cpu->name.length == 0) + { + if(cpuUarch.length > 0) + { + if(cpu->name.length > 0) + ffStrbufAppendC(&cpu->name, ' '); + ffStrbufAppend(&cpu->name, &cpuUarch); + } + + if(cpuIsa.length > 0) + { + parseIsa(&cpuIsa); + if(cpu->name.length > 0) + ffStrbufAppendC(&cpu->name, ' '); + ffStrbufAppend(&cpu->name, &cpuIsa); + } + } #endif return NULL;