4 #include "MacCompatibility.h"
11 typedef long long __int64;
12 typedef __int64 LARGE_INTEGER;
13 static int QueryPerformanceFrequency(LARGE_INTEGER *liptr)
15 assert(sizeof (__int64) == 8);
16 assert(sizeof (LARGE_INTEGER) == 8);
21 static void QueryPerformanceCounter(LARGE_INTEGER *liptr)
24 gettimeofday(&tv, NULL);
25 *liptr = ( (((LARGE_INTEGER) tv.tv_sec) * 1000) +
26 (((LARGE_INTEGER) tv.tv_usec) / 1000) );
38 QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
39 QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
41 __int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
44 static AppTime g_appTime;
47 void CopyCStringToPascal( const char* src, unsigned char dst[256])
49 int len = strlen( src);
51 memcpy( dst + 1, src, len);
55 void CopyPascalStringToC( const unsigned char* src, char* dst)
58 memcpy( dst, src + 1, len);
66 QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
68 counter -= g_appTime.baseCounter;
71 time.lo = (unsigned long)counter;
72 time.hi = (unsigned long)(counter >> 32);
77 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
82 __int64 value2 = b.hi;
88 return durationImmediate;
90 __int64 frac = value % g_appTime.counterRate;
91 value /= g_appTime.counterRate;
98 frac /= g_appTime.counterRate;
99 time = (Duration)frac;
104 frac /= g_appTime.counterRate;
107 time = (Duration)value;
114 static char g_filename[ 256];
115 char* ConvertFileName( const char* orgfilename)
117 // translate filename into proper path name
118 if (orgfilename[ 0] == ':')
120 strcpy( g_filename, orgfilename);
122 for (int n = 0; g_filename[ n]; n++)
124 if (g_filename[ n] == ':')
125 g_filename[ n] = '/';