From 7d0256fb857886bce14604bd0dd9841298684ad2 Mon Sep 17 00:00:00 2001 From: Stian Halseth <33956011+shalseth@users.noreply.github.com> Date: Tue, 8 Sep 2026 14:31:55 +0200 Subject: [PATCH] CPU (Linux): adds SPARC support (#2572) /proc/cpuinfo on sparc has none of the fields the generic fallback looks for, so the module printed "Unknown (64)". The name is in "cpu", and the frequency in "CpuClkTck" -- in Hz, hex on sparc64, decimal on sparc32. --- CHANGELOG.md | 5 +++++ src/detection/cpu/cpu_linux.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1c3fbcf..786fbef96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Unreleased + +Features: +* Added CPU name and frequency detection support on SPARC. (CPU, Linux) + # 2.68.1 Changes: diff --git a/src/detection/cpu/cpu_linux.c b/src/detection/cpu/cpu_linux.c index 4a338ea4e..152827294 100644 --- a/src/detection/cpu/cpu_linux.c +++ b/src/detection/cpu/cpu_linux.c @@ -619,6 +619,9 @@ static const char* parseCpuInfo( (cpu->name.length == 0 && ffParsePropLine(line, "cpu :", &cpu->name)) || #elif __sh__ (cpu->name.length == 0 && ffParsePropLine(line, "cpu type :", &cpu->name)) || +#elif __sparc__ || __sparc + (cpu->name.length == 0 && ffParsePropLine(line, "cpu :", &cpu->name)) || + (cpuMHz->length == 0 && ffParsePropLine(line, "Cpu0ClkTck :", cpuMHz)) || #else (cpu->name.length == 0 && ffParsePropLine(line, "model name :", &cpu->name)) || (cpu->name.length == 0 && ffParsePropLine(line, "model :", &cpu->name)) || @@ -1101,6 +1104,10 @@ static const char* detectPhysicalCores(FFCPUResult* cpu) { if (cpu->name.length) { ffStrbufPrependS(&cpu->name, "Machine "); } + #elif __sparc__ || __sparc + // Cpu0ClkTck is in Hz, printed as "%016lx" by sparc64 and "%ld" by sparc32. A 32-bit userland can run + // on a 64-bit kernel, so take the base from the width of the value rather than from our own bitness. + cpu->frequencyBase = (uint32_t) (strtoull(cpuMHz.chars, nullptr, cpuMHz.length == 16 ? 16 : 10) / 1000000); #endif }