mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-16 02:13:46 +12:00
[macos] fix temp sensor on system with many cores
This commit is contained in:
parent
1b126f55e3
commit
dcbdb7360d
|
@ -18,6 +18,9 @@ tab-size = 4
|
|||
|
||||
#include "smc.hpp"
|
||||
|
||||
static constexpr size_t MaxIndexCount = sizeof("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") - 1;
|
||||
static constexpr const char *KeyIndexes = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
static UInt32 _strtoul(char *str, int size, int base) {
|
||||
UInt32 total = 0;
|
||||
int i;
|
||||
|
@ -91,13 +94,16 @@ namespace Cpu {
|
|||
// according to VirtualSMC docs (hackintosh fake SMC) the enumeration follows with alphabetic chars - not implemented yet here (nor in VirtualSMC)
|
||||
long long SMCConnection::getTemp(int core) {
|
||||
char key[] = SMC_KEY_CPU_TEMP;
|
||||
if (core > MaxIndexCount) {
|
||||
return -1;
|
||||
}
|
||||
if (core >= 0) {
|
||||
snprintf(key, 5, "TC%1dc", core);
|
||||
snprintf(key, 5, "TC%1cc", KeyIndexes[core]);
|
||||
}
|
||||
long long result = getSMCTemp(key);
|
||||
if (result == -1) {
|
||||
// try again with C
|
||||
snprintf(key, 5, "TC%1dC", core);
|
||||
snprintf(key, 5, "TC%1dC", KeyIndexes[core]);
|
||||
result = getSMCTemp(key);
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue