WinRT: bug-fix - SDL_SetThreadPriority() didn't work on WinRT 8.x platforms

WinRT 8.0 (Phone and non-Phone) didn't offer an API to set an already-created
thread's priority.  WinRT 8.1 offered this API, along with several other
Win32 thread functions that were previously unavailable (in WinRT).

This change makes WinRT 8.1+ platforms use SDL's Win32 backend.
This commit is contained in:
David Ludwig 2015-11-26 13:51:03 -05:00
parent bcb2c8ba3c
commit c858ba8394
8 changed files with 70 additions and 53 deletions

View file

@ -45,7 +45,11 @@ SDL_CreateMutex(void)
if (mutex) {
/* Initialize */
/* On SMP systems, a non-zero spin count generally helps performance */
#if __WINRT__
InitializeCriticalSectionEx(&mutex->cs, 2000, 0);
#else
InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000);
#endif
} else {
SDL_OutOfMemory();
}

View file

@ -45,7 +45,11 @@ SDL_CreateSemaphore(Uint32 initial_value)
sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
if (sem) {
/* Create the semaphore, with max value 32K */
#if __WINRT__
sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS);
#else
sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL);
#endif
sem->count = initial_value;
if (!sem->id) {
SDL_SetError("Couldn't create semaphore");
@ -86,7 +90,11 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
} else {
dwMilliseconds = (DWORD) timeout;
}
#if __WINRT__
switch (WaitForSingleObjectEx(sem->id, dwMilliseconds, FALSE)) {
#else
switch (WaitForSingleObject(sem->id, dwMilliseconds)) {
#endif
case WAIT_OBJECT_0:
InterlockedDecrement(&sem->count);
retval = 0;

View file

@ -106,7 +106,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread)
{
#elif defined(__CYGWIN__)
#elif defined(__CYGWIN__) || defined(__WINRT__)
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
@ -230,7 +230,11 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
void
SDL_SYS_WaitThread(SDL_Thread * thread)
{
#if __WINRT__
WaitForSingleObjectEx(thread->handle, INFINITE, FALSE);
#else
WaitForSingleObject(thread->handle, INFINITE);
#endif
CloseHandle(thread->handle);
}