make this static, so it can be used before main()
This commit is contained in:
@@ -38,8 +38,12 @@ public:
|
||||
*
|
||||
* 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".
|
||||
*
|
||||
* 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();
|
||||
|
||||
@@ -185,18 +185,25 @@ void ArchHooks_Win32::SetTime( tm newtime )
|
||||
SetLocalTime( &st );
|
||||
}
|
||||
|
||||
int64_t ArchHooks_Win32::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
static bool bInitialized;
|
||||
static DWORD iStartTime;
|
||||
if( !bInitialized )
|
||||
{
|
||||
timeBeginPeriod( 1 );
|
||||
bInitialized = true;
|
||||
iStartTime = timeGetTime();
|
||||
}
|
||||
static bool g_bTimerInitialized;
|
||||
static DWORD g_iStartTime;
|
||||
|
||||
return (timeGetTime() - iStartTime) * 1000;
|
||||
static void InitTimer()
|
||||
{
|
||||
if( g_bTimerInitialized )
|
||||
return;
|
||||
g_bTimerInitialized = true;
|
||||
|
||||
timeBeginPeriod( 1 );
|
||||
g_iStartTime = timeGetTime();
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
if( !g_bTimerInitialized )
|
||||
InitTimer();
|
||||
|
||||
return (timeGetTime() - g_iStartTime) * 1000;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,7 +17,6 @@ public:
|
||||
void EnterTimeCriticalSection();
|
||||
void ExitTimeCriticalSection();
|
||||
void SetTime( tm newtime );
|
||||
int64_t GetMicrosecondsSinceStart( bool bAccurate );
|
||||
|
||||
private:
|
||||
void CheckVideoDriver();
|
||||
|
||||
Reference in New Issue
Block a user