diff --git a/CHANGELOG.md b/CHANGELOG.md index ed1c3fbcfe..786fbef96e 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 4a338ea4e8..152827294a 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 }