04-09-2013 01:41 PM
04-11-2013 12:01 PM
04-12-2013 01:23 AM
Lock::Lock(unsigned spinCount)
{
// Try to load function dynamically so that we don't require NT
// On Windows NT we will use InitializeCriticalSectionAndSpinCount
static bool initTried = 0;
static Function_InitializeCriticalSectionAndSpinCount pInitFn = 0;
if (!initTried)
{
HMODULE hmodule = ::LoadLibrary(OVR_STR("kernel32.dll"));
pInitFn = (Function_InitializeCriticalSectionAndSpinCount)
::GetProcAddress(hmodule, "InitializeCriticalSectionAndSpinCount");
initTried = 1;
}
// Initialize the critical section
if (pInitFn)
pInitFn(&cs, spinCount);
else
::InitializeCriticalSection(&cs);
}
04-13-2013 04:32 AM
"kojack" wrote:
From ovr_atomic.cpp:
In Winrt you can't call LoadLibrary, InitializeCriticalSectionAndSpinCount or InitializeCriticalSection.
GetProcAddress still works (you need to get the library handle from LoadPackageLibrary, which won't load kernel32).
There's InitializeCriticalSectionEx (which has a spincount). But it's only available on Vista and above.
Then again, windows 8 metro apps can't run on older windows anyway, so if you build ovr for windows 8 metro then a define could replace all that code with InitializeCriticalSectionEx instead of trying to decide at runtime if the function is there.
04-13-2013 06:17 PM
04-13-2013 06:40 PM
04-13-2013 07:32 PM