X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FMacCompatibility.cpp;h=4ed303322a9f854cd1348c969978719d1cad4d61;hb=b9a46d8e2b7e7e22c706e7dd3734f31015db4408;hp=6e47632f0a0260b1ea5c66b54aaac00b7ed7f311;hpb=11ff9aec2c3206a5b9df5bf8815051458628c45a;p=lugaru.git diff --git a/Source/MacCompatibility.cpp b/Source/MacCompatibility.cpp index 6e47632..4ed3033 100644 --- a/Source/MacCompatibility.cpp +++ b/Source/MacCompatibility.cpp @@ -18,52 +18,53 @@ You should have received a copy of the GNU General Public License along with Lugaru. If not, see . */ -/**> HEADER FILES <**/ -#include "MacCompatibility.h" +#include "MacCompatibility.hpp" + +#include +#include +#include +#include +#include #ifdef WIN32 #include #endif -#include -#include -#include -#include -#include - #if PLATFORM_UNIX -#include -#include -#include #include +#include +#include +#include + typedef long long __int64; typedef __int64 LARGE_INTEGER; -static int QueryPerformanceFrequency(LARGE_INTEGER *liptr) +static int QueryPerformanceFrequency(LARGE_INTEGER* liptr) { - assert(sizeof (__int64) == 8); - assert(sizeof (LARGE_INTEGER) == 8); + assert(sizeof(__int64) == 8); + assert(sizeof(LARGE_INTEGER) == 8); *liptr = 1000; - return(1); + return (1); } -static int QueryPerformanceCounter(LARGE_INTEGER *liptr) +static int QueryPerformanceCounter(LARGE_INTEGER* liptr) { struct timeval tv; gettimeofday(&tv, NULL); - *liptr = ( (((LARGE_INTEGER) tv.tv_sec) * 1000) + - (((LARGE_INTEGER) tv.tv_usec) / 1000) ); - return(1); + *liptr = ((((LARGE_INTEGER)tv.tv_sec) * 1000) + + (((LARGE_INTEGER)tv.tv_usec) / 1000)); + return (1); } #endif class AppTime { -public: - AppTime() { + public: + AppTime() + { counterRate = 1; baseCounter = 0; - QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate); - QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter); + QueryPerformanceFrequency((LARGE_INTEGER*)&counterRate); + QueryPerformanceCounter((LARGE_INTEGER*)&baseCounter); } __int64 counterRate; // LARGE_INTEGER type has no math functions so use int64 __int64 baseCounter; @@ -73,7 +74,7 @@ static AppTime g_appTime; AbsoluteTime UpTime() { __int64 counter; - QueryPerformanceCounter( (LARGE_INTEGER*)&counter); + QueryPerformanceCounter((LARGE_INTEGER*)&counter); counter -= g_appTime.baseCounter; @@ -83,8 +84,7 @@ AbsoluteTime UpTime() return time; } - -Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b) +Duration AbsoluteDeltaToDuration(AbsoluteTime& a, AbsoluteTime& b) { __int64 value = a.hi; value <<= 32; @@ -94,8 +94,9 @@ Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b) value2 |= b.lo; value -= value2; - if (value <= 0) + if (value <= 0) { return durationImmediate; + } __int64 frac = value % g_appTime.counterRate; value /= g_appTime.counterRate;