mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-10 22:44:48 +12:00
don't crash on intel
This commit is contained in:
parent
9f88187c29
commit
c252c618c0
|
@ -52,7 +52,7 @@ double getValue(IOHIDServiceClientRef sc) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern C
|
} // extern C
|
||||||
|
|
||||||
unordered_flat_map<int, double> Cpu::ThermalSensors::getSensors() {
|
unordered_flat_map<int, double> Cpu::ThermalSensors::getSensors() {
|
||||||
unordered_flat_map<int, double> cpuValues;
|
unordered_flat_map<int, double> cpuValues;
|
||||||
|
@ -62,29 +62,30 @@ unordered_flat_map<int, double> Cpu::ThermalSensors::getSensors() {
|
||||||
IOHIDEventSystemClientRef system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
|
IOHIDEventSystemClientRef system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
|
||||||
IOHIDEventSystemClientSetMatching(system, thermalSensors);
|
IOHIDEventSystemClientSetMatching(system, thermalSensors);
|
||||||
CFArrayRef matchingsrvs = IOHIDEventSystemClientCopyServices(system);
|
CFArrayRef matchingsrvs = IOHIDEventSystemClientCopyServices(system);
|
||||||
|
if (matchingsrvs) {
|
||||||
long count = CFArrayGetCount(matchingsrvs);
|
long count = CFArrayGetCount(matchingsrvs);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
IOHIDServiceClientRef sc = (IOHIDServiceClientRef)CFArrayGetValueAtIndex(matchingsrvs, i);
|
IOHIDServiceClientRef sc = (IOHIDServiceClientRef)CFArrayGetValueAtIndex(matchingsrvs, i);
|
||||||
if (sc) {
|
if (sc) {
|
||||||
CFStringRef name = IOHIDServiceClientCopyProperty(sc, CFSTR("Product")); // here we use ...CopyProperty
|
CFStringRef name = IOHIDServiceClientCopyProperty(sc, CFSTR("Product")); // here we use ...CopyProperty
|
||||||
if (name) {
|
if (name) {
|
||||||
char buf[200];
|
char buf[200];
|
||||||
CFStringGetCString(name, buf, 200, kCFStringEncodingASCII);
|
CFStringGetCString(name, buf, 200, kCFStringEncodingASCII);
|
||||||
std::string n(buf);
|
std::string n(buf);
|
||||||
if (n.starts_with("PMU tdie")) {
|
if (n.starts_with("PMU tdie")) {
|
||||||
std::string indexString = n.substr(8, 1);
|
std::string indexString = n.substr(8, 1);
|
||||||
int index = stoi(indexString);
|
int index = stoi(indexString);
|
||||||
cpuValues[index - 1] = getValue(sc);
|
cpuValues[index - 1] = getValue(sc);
|
||||||
} else if (n == "SOC MTR Temp Sensor0") {
|
} else if (n == "SOC MTR Temp Sensor0") {
|
||||||
cpuValues[0] = getValue(sc); // package T for Apple Silicon
|
cpuValues[0] = getValue(sc); // package T for Apple Silicon
|
||||||
|
}
|
||||||
|
CFRelease(name);
|
||||||
}
|
}
|
||||||
CFRelease(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CFRelease(matchingsrvs);
|
||||||
}
|
}
|
||||||
CFRelease(matchingsrvs);
|
CFRelease(system);
|
||||||
CFRelease(system);
|
|
||||||
CFRelease(thermalSensors);
|
CFRelease(thermalSensors);
|
||||||
return cpuValues;
|
return cpuValues;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue