fix CPU frequency+linux memory fallback

This commit is contained in:
deepend committed 2026-12-04 18:28:37 -06:00
1 parent 487b7d8721
commit 27f5730f50
5 files changed
+192 -51

No files matched your search

+11
View File
@@ -505,7 +505,18 @@ sysinfo_backend_get_os (void)
char *
sysinfo_backend_get_cpu (void)
{
static const WCHAR cpu_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
DWORD mhz = 0;
ensure_cpu_snapshot ();
if (!snapshot.cpu)
return NULL;
/* The registry's reported MHz is not a guaranteed live or turbo clock. */
if (read_registry_dword (HKEY_LOCAL_MACHINE, cpu_key, L"~MHz", &mhz) && mhz && mhz <= 100000)
{
if (mhz >= 1000)
return g_strdup_printf ("%s" SYSINFO_SEP "reported %.2f GHz", snapshot.cpu, (double) mhz / 1000.0);
return g_strdup_printf ("%s" SYSINFO_SEP "reported %lu MHz", snapshot.cpu, (unsigned long) mhz);
}
return g_strdup (snapshot.cpu);
}