Try to avoid direct initialization

This commit is contained in:
twinaphex 2017-08-06 01:44:34 +02:00
parent 944eb01fb4
commit e259a8c63b
1 changed files with 8 additions and 1 deletions

View File

@ -441,8 +441,9 @@ static bool _scond_wait_win32(scond_t *cond, slock_t *lock, DWORD dwMilliseconds
struct QueueEntry **ptr; struct QueueEntry **ptr;
#if _WIN32_WINNT >= 0x0500 #if _WIN32_WINNT >= 0x0500
static LARGE_INTEGER performanceCounterFrequency = { .QuadPart = 0 }; static LARGE_INTEGER performanceCounterFrequency;
LARGE_INTEGER tsBegin; LARGE_INTEGER tsBegin;
static bool first_init = true;
#else #else
static bool beginPeriod = false; static bool beginPeriod = false;
DWORD tsBegin; DWORD tsBegin;
@ -460,6 +461,12 @@ static bool _scond_wait_win32(scond_t *cond, slock_t *lock, DWORD dwMilliseconds
/* since this library is meant for realtime game software /* since this library is meant for realtime game software
* I have no problem setting this to 1 and forgetting about it. */ * I have no problem setting this to 1 and forgetting about it. */
#if _WIN32_WINNT >= 0x0500 #if _WIN32_WINNT >= 0x0500
if (first_init)
{
performanceCounterFrequency.QuadPart = 0;
first_init = false;
}
if (performanceCounterFrequency.QuadPart == 0) if (performanceCounterFrequency.QuadPart == 0)
{ {
QueryPerformanceFrequency(&performanceCounterFrequency); QueryPerformanceFrequency(&performanceCounterFrequency);