netstar pushed a commit to branch master. http://git.enlightenment.org/apps/evisum.git/commit/?id=779af23183f02e4d4c4d9ad6798ef2bc44b9a81d
commit 779af23183f02e4d4c4d9ad6798ef2bc44b9a81d Author: Alastair Poole <nets...@gmail.com> Date: Sun Sep 6 14:09:28 2020 +0100 linux: current cpu freq. Not sure if there is a 3rd fallback... --- src/bin/system/machine/cpu.bogox | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/bin/system/machine/cpu.bogox b/src/bin/system/machine/cpu.bogox index 8e9999c..0695c59 100644 --- a/src/bin/system/machine/cpu.bogox +++ b/src/bin/system/machine/cpu.bogox @@ -294,7 +294,39 @@ system_cpu_frequency_get(void) if (sysctl(mib, sizeof(mib), &freq, &len, NULL, 0) != -1) freq *= 1000; #elif defined(__linux__) + FILE *f; + char buf[4096]; + int tmp; + + f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r"); + if (f) + { + if (fgets(buf, sizeof(buf), f)) + { + tmp = strtol(buf, NULL, 10); + if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE)) + freq = tmp; + } + fclose(f); + if (freq != -1) return freq; + } + + f = fopen("/proc/cpuinfo", "r"); + if (!f) return freq; + while (fgets(buf, sizeof(buf), f)) + { + if (!strncasecmp(buf, "cpu MHz", 7)) + { + char *s = strchr(buf, ':') + 1; + tmp = strtol(s, NULL, 10); + if (!((tmp == LONG_MIN || tmp == LONG_MAX) && errno == ERANGE)) + tmp *= 1000; + break; + } + } + + fclose(f); #else #endif --