From e259a8c63bda0de1e89d3fff99bf0f4f15fcdbd0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 6 Aug 2017 01:44:34 +0200 Subject: [PATCH] Try to avoid direct initialization --- libretro-common/rthreads/rthreads.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index 1abcf1a3ed..a059bc2f04 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -441,8 +441,9 @@ static bool _scond_wait_win32(scond_t *cond, slock_t *lock, DWORD dwMilliseconds struct QueueEntry **ptr; #if _WIN32_WINNT >= 0x0500 - static LARGE_INTEGER performanceCounterFrequency = { .QuadPart = 0 }; + static LARGE_INTEGER performanceCounterFrequency; LARGE_INTEGER tsBegin; + static bool first_init = true; #else static bool beginPeriod = false; 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 * I have no problem setting this to 1 and forgetting about it. */ #if _WIN32_WINNT >= 0x0500 + if (first_init) + { + performanceCounterFrequency.QuadPart = 0; + first_init = false; + } + if (performanceCounterFrequency.QuadPart == 0) { QueryPerformanceFrequency(&performanceCounterFrequency);