mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-12 07:25:08 +12:00
switch to other way to get CPU freq (still does not work)
This commit is contained in:
parent
cf51ba2ebe
commit
155c848b97
|
@ -262,12 +262,15 @@ namespace Cpu {
|
||||||
}
|
}
|
||||||
|
|
||||||
string get_cpuHz() {
|
string get_cpuHz() {
|
||||||
int64_t freq = 1;
|
unsigned int freq = 1;
|
||||||
size_t size = sizeof(freq);
|
size_t size = sizeof(freq);
|
||||||
|
|
||||||
if (sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0) < 0) {
|
int mib[2];
|
||||||
char *err = strerror(errno);
|
mib[0] = CTL_HW;
|
||||||
Logger::error("Failed to get CPU frequency: " + string(err));
|
mib[1] = HW_CPU_FREQ;
|
||||||
|
|
||||||
|
if (sysctl(mib, 2, &freq, &size, NULL, 0) < 0) {
|
||||||
|
Logger::error("Failed to get CPU frequency: " + std::to_string(errno));
|
||||||
}
|
}
|
||||||
return std::to_string(freq);
|
return std::to_string(freq);
|
||||||
}
|
}
|
||||||
|
@ -359,7 +362,7 @@ namespace Cpu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CFRelease(one_ps_descriptor);
|
CFRelease(one_ps_descriptor);
|
||||||
} else {
|
} else {
|
||||||
has_battery = false;
|
has_battery = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue