diff options
| author | Jonathan "Geenz" Goodman <geenz@lindenlab.com> | 2025-10-17 16:56:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-17 16:56:48 -0400 |
| commit | aec7bf19ebffd9d6b60c68e31de723eabd6aa98a (patch) | |
| tree | 9ee0b36fa08a99444260baaf5ea9b019758bb125 /indra/llcommon/llprocessor.cpp | |
| parent | e81b1de01e2b28f83cd2c85691428211bb9105e9 (diff) | |
| parent | 57a9e51360aebf142bbbdc2663f68ebacfb7d8f5 (diff) | |
Merge pull request #4714 from secondlife/release/2025.07
Release/2025.07
Diffstat (limited to 'indra/llcommon/llprocessor.cpp')
| -rw-r--r-- | indra/llcommon/llprocessor.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 2e94651083..718f471321 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -628,6 +628,8 @@ private: #elif LL_DARWIN +#include <CoreFoundation/CoreFoundation.h> +#include <IOKit/IOKitLib.h> #include <mach/machine.h> #include <sys/sysctl.h> @@ -638,25 +640,21 @@ public: { getCPUIDInfo(); uint64_t frequency = getSysctlInt64("hw.cpufrequency"); - if (!frequency) + if (frequency == 0) // fallback to clockrate and tbfrequency { - auto tbfrequency = getSysctlInt64("hw.tbfrequency"); - struct clockinfo clockrate; - auto clockrate_len = sizeof(clockrate); - if (!sysctlbyname("kern.clockrate", &clockrate, &clockrate_len, NULL, 0)) - frequency = tbfrequency * clockrate.hz; + frequency = getSysctlClockrate() * getSysctlInt64("hw.tbfrequency"); } setInfo(eFrequency, (F64)frequency / (F64)1000000); } - virtual ~LLProcessorInfoDarwinImpl() {} + virtual ~LLProcessorInfoDarwinImpl() = default; private: int getSysctlInt(const char* name) { int result = 0; size_t len = sizeof(int); - int error = sysctlbyname(name, (void*)&result, &len, NULL, 0); + int error = sysctlbyname(name, (void*)&result, &len, nullptr, 0); return error == -1 ? 0 : result; } @@ -664,7 +662,7 @@ private: { uint64_t value = 0; size_t size = sizeof(value); - int result = sysctlbyname(name, (void*)&value, &size, NULL, 0); + int result = sysctlbyname(name, (void*)&value, &size, nullptr, 0); if ( result == 0 ) { if ( size == sizeof( uint64_t ) ) @@ -684,6 +682,14 @@ private: return result == -1 ? 0 : value; } + uint64_t getSysctlClockrate() + { + struct clockinfo clockrate{}; + size_t size = sizeof(clockrate); + int error = sysctlbyname("kern.clockrate", &clockrate, &size, nullptr, 0); + return error == -1 ? 0 : clockrate.hz; + } + void getCPUIDInfo() { size_t len = 0; |
