summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-06-06 17:17:49 +0300
committerGitHub <noreply@github.com>2024-06-06 17:17:49 +0300
commit8f6e50ed6a8b2a3f7b2a173bf7c535aac13f22b5 (patch)
tree164ce475033328c403e49eafc81cbb5c1ac9ea6d
parent94a18c43f5153fd50b7350b45d6b221aa80cb269 (diff)
parent2117dca25e1d15cbbf9def774ec0fac29e5c01dd (diff)
Merge pull request #1636 from megapahit/macos-arm64
* An alternative in getting CPU freq on M-series This solution was retrieved from https://listman.redhat.com/archives/libvir-list/2022-February/228217.html sysctl hw.cpufrequency would result as empty on Apple Silicon (at least) M1, when run natively. Ironically (and that's why it's been working with viewers relying on Rosetta 2), arch -x86_64 /bin/bash -c 'sysctl hw.cpufrequency' run on an Apple Silicon would result in the correct number. * tbfreq x clockrate.hz only when cpufrequency is 0 Just maybe M3 implements cpufrequency, which should be more accurate than the alternative (different results on my Intel Mac).
-rw-r--r--indra/llcommon/llprocessor.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 9d53b9be35..d3ff48073d 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -638,6 +638,14 @@ public:
{
getCPUIDInfo();
uint64_t frequency = getSysctlInt64("hw.cpufrequency");
+ if (!frequency)
+ {
+ 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;
+ }
setInfo(eFrequency, (F64)frequency / (F64)1000000);
}