make this static, so it can be used before main()

This commit is contained in:
Glenn Maynard
2004-06-11 01:01:31 +00:00
parent 49446552c9
commit 7aee50e5fd
3 changed files with 23 additions and 13 deletions
+5 -1
View File
@@ -38,8 +38,12 @@ public:
* *
* Note that bAccurate may change the result significantly; it may use a different * Note that bAccurate may change the result significantly; it may use a different
* timer, and may have a different concept of when the program "started". * timer, and may have a different concept of when the program "started".
*
* This is a static function, implemented in whichever ArchHooks source is used,
* so it can be used at any time (such as in global constructors), before HOOKS
* is initialized.
*/ */
virtual int64_t GetMicrosecondsSinceStart( bool bAccurate ) = 0; static int64_t GetMicrosecondsSinceStart( bool bAccurate );
}; };
ArchHooks *MakeArchHooks(); ArchHooks *MakeArchHooks();
@@ -185,18 +185,25 @@ void ArchHooks_Win32::SetTime( tm newtime )
SetLocalTime( &st ); SetLocalTime( &st );
} }
int64_t ArchHooks_Win32::GetMicrosecondsSinceStart( bool bAccurate ) static bool g_bTimerInitialized;
{ static DWORD g_iStartTime;
static bool bInitialized;
static DWORD iStartTime; static void InitTimer()
if( !bInitialized )
{ {
if( g_bTimerInitialized )
return;
g_bTimerInitialized = true;
timeBeginPeriod( 1 ); timeBeginPeriod( 1 );
bInitialized = true; g_iStartTime = timeGetTime();
iStartTime = timeGetTime();
} }
return (timeGetTime() - iStartTime) * 1000; int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
{
if( !g_bTimerInitialized )
InitTimer();
return (timeGetTime() - g_iStartTime) * 1000;
} }
/* /*
@@ -17,7 +17,6 @@ public:
void EnterTimeCriticalSection(); void EnterTimeCriticalSection();
void ExitTimeCriticalSection(); void ExitTimeCriticalSection();
void SetTime( tm newtime ); void SetTime( tm newtime );
int64_t GetMicrosecondsSinceStart( bool bAccurate );
private: private:
void CheckVideoDriver(); void CheckVideoDriver();