From 0e672b866e36b47de70a583615ff76364e999275 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Wed, 13 Apr 2016 19:24:51 +0200 Subject: [PATCH] Determine CPU speed on FreeBSD --- Sources/Engine/Base/Timer.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/Engine/Base/Timer.cpp b/Sources/Engine/Base/Timer.cpp index 43be607..8922297 100644 --- a/Sources/Engine/Base/Timer.cpp +++ b/Sources/Engine/Base/Timer.cpp @@ -37,6 +37,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #endif +#if PLATFORM_FREEBSD +#include +#include +#endif + // Read the Pentium TimeStampCounter (or something like that). static inline __int64 ReadTSC(void) { @@ -340,6 +345,13 @@ CTimer::CTimer(BOOL bInterrupt /*=TRUE*/) #elif PLATFORM_MACOSX tm_llPerformanceCounterFrequency = tm_llCPUSpeedHZ = ((__int64) GetCPUSpeed()) * 1000000; +#elif PLATFORM_FREEBSD + __int64 mhz = 0; + size_t len = sizeof(mhz); + + sysctlbyname("hw.clockrate", &mhz, &len, NULL, 0); + tm_llPerformanceCounterFrequency = tm_llCPUSpeedHZ = (__int64) (mhz * 1000000); + #else // !!! FIXME : This is an ugly hack. double mhz = 0.0;