4 #include "MacCompatibility.h"
20 typedef long long __int64;
21 typedef __int64 LARGE_INTEGER;
22 static int QueryPerformanceFrequency(LARGE_INTEGER *liptr)
24 assert(sizeof (__int64) == 8);
25 assert(sizeof (LARGE_INTEGER) == 8);
30 static int QueryPerformanceCounter(LARGE_INTEGER *liptr)
33 gettimeofday(&tv, NULL);
34 *liptr = ( (((LARGE_INTEGER) tv.tv_sec) * 1000) +
35 (((LARGE_INTEGER) tv.tv_usec) / 1000) );
47 QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
48 QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
50 __int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
53 static AppTime g_appTime;
56 void CopyCStringToPascal( const char* src, unsigned char dst[256])
58 int len = strlen( src);
60 memcpy( dst + 1, src, len);
64 void CopyPascalStringToC( const unsigned char* src, char* dst)
67 memcpy( dst, src + 1, len);
75 QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
77 counter -= g_appTime.baseCounter;
80 time.lo = (unsigned long)counter;
81 time.hi = (unsigned long)(counter >> 32);
86 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
91 __int64 value2 = b.hi;
97 return durationImmediate;
99 __int64 frac = value % g_appTime.counterRate;
100 value /= g_appTime.counterRate;
107 frac /= g_appTime.counterRate;
108 time = (Duration)frac;
113 frac /= g_appTime.counterRate;
116 time = (Duration)value;
123 static char g_filename[ 256];
124 char* ConvertFileName( const char* orgfilename)
126 // translate filename into proper path name
127 if (orgfilename[ 0] == ':')
129 strcpy( g_filename, orgfilename);
131 for (int n = 0; g_filename[ n]; n++)
133 if (g_filename[ n] == ':')
134 g_filename[ n] = '/';