X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FMacCompatibility.cpp;h=4ed303322a9f854cd1348c969978719d1cad4d61;hb=a15391fb6e514e033a50c714ef32968d21419f19;hp=ac0e63cfdd664a5961d370347eacb4068c7c1b81;hpb=ed3662c0852c4312a612b4fc35bd03aba8d13db7;p=lugaru.git diff --git a/Source/MacCompatibility.cpp b/Source/MacCompatibility.cpp index ac0e63c..4ed3033 100644 --- a/Source/MacCompatibility.cpp +++ b/Source/MacCompatibility.cpp @@ -20,11 +20,11 @@ along with Lugaru. If not, see . #include "MacCompatibility.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef WIN32 #include @@ -32,38 +32,39 @@ along with Lugaru. If not, see . #if PLATFORM_UNIX #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;