WinRT: merged with SDL 2.0.1 codebase
This commit is contained in:
commit
59df93166d
344 changed files with 12745 additions and 7248 deletions
|
@ -26,6 +26,7 @@
|
|||
#define _SDL_systhread_h
|
||||
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_thread_c.h"
|
||||
|
||||
/* This function creates a thread, passing args to SDL_RunThread(),
|
||||
saves a system-dependent thread id in thread->id, and returns 0
|
||||
|
|
|
@ -125,6 +125,7 @@ SDL_Generic_GetTLSData()
|
|||
SDL_TLSEntry *entry;
|
||||
SDL_TLSData *storage = NULL;
|
||||
|
||||
#if !SDL_THREADS_DISABLED
|
||||
if (!SDL_generic_TLS_mutex) {
|
||||
static SDL_SpinLock tls_lock;
|
||||
SDL_AtomicLock(&tls_lock);
|
||||
|
@ -139,6 +140,7 @@ SDL_Generic_GetTLSData()
|
|||
}
|
||||
SDL_AtomicUnlock(&tls_lock);
|
||||
}
|
||||
#endif /* SDL_THREADS_DISABLED */
|
||||
|
||||
SDL_MemoryBarrierAcquire();
|
||||
SDL_LockMutex(SDL_generic_TLS_mutex);
|
||||
|
@ -148,7 +150,9 @@ SDL_Generic_GetTLSData()
|
|||
break;
|
||||
}
|
||||
}
|
||||
#if !SDL_THREADS_DISABLED
|
||||
SDL_UnlockMutex(SDL_generic_TLS_mutex);
|
||||
#endif
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#ifndef _SDL_thread_c_h
|
||||
#define _SDL_thread_c_h
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* Need the definitions of SYS_ThreadHandle */
|
||||
#if SDL_THREADS_DISABLED
|
||||
#include "generic/SDL_systhread_c.h"
|
||||
|
|
|
@ -156,10 +156,10 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
|
|||
#else
|
||||
end = SDL_GetTicks() + timeout;
|
||||
while ((retval = SDL_SemTryWait(sem)) == SDL_MUTEX_TIMEDOUT) {
|
||||
if ((SDL_GetTicks() - end) >= 0) {
|
||||
if (SDL_TICKS_PASSED(SDL_GetTicks(), end)) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(0);
|
||||
SDL_Delay(1);
|
||||
}
|
||||
#endif /* HAVE_SEM_TIMEDWAIT */
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
int
|
||||
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
||||
{
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex;
|
||||
pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex;
|
||||
pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex;
|
||||
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
|
||||
pThreadStartParms pThreadParms =
|
||||
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
|
||||
|
@ -145,7 +145,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4733)
|
||||
#pragma pack(push,8)
|
||||
typedef struct tagTHREADNAME_INFO
|
||||
{
|
||||
|
@ -155,28 +157,46 @@ typedef struct tagTHREADNAME_INFO
|
|||
DWORD dwFlags; /* reserved for future use, must be zero */
|
||||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
|
||||
static EXCEPTION_DISPOSITION
|
||||
ignore_exception(void *a, void *b, void *c, void *d)
|
||||
{
|
||||
return ExceptionContinueExecution;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void
|
||||
SDL_SYS_SetupThread(const char *name)
|
||||
{
|
||||
if (name != NULL) {
|
||||
#if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */
|
||||
#ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */
|
||||
/* This magic tells the debugger to name a thread if it's listening. */
|
||||
#if 0 /* !!! FIXME: revisit this later. See https://bugzilla.libsdl.org/show_bug.cgi?id=2089 */
|
||||
#if (defined(_MSC_VER) && defined(_M_IX86))
|
||||
/* This magic tells the debugger to name a thread if it's listening.
|
||||
The inline asm sets up SEH (__try/__except) without C runtime
|
||||
support. See Microsoft Systems Journal, January 1997:
|
||||
http://www.microsoft.com/msj/0197/exception/exception.aspx */
|
||||
INT_PTR handler = (INT_PTR) ignore_exception;
|
||||
THREADNAME_INFO inf;
|
||||
|
||||
inf.dwType = 0x1000;
|
||||
inf.szName = name;
|
||||
inf.dwThreadID = (DWORD) -1;
|
||||
inf.dwFlags = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf);
|
||||
__asm { /* set up SEH */
|
||||
push handler
|
||||
push fs:[0]
|
||||
mov fs:[0],esp
|
||||
}
|
||||
__except(EXCEPTION_CONTINUE_EXECUTION)
|
||||
{
|
||||
/* The program itself should ignore this bogus exception. */
|
||||
|
||||
/* The program itself should ignore this bogus exception. */
|
||||
RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf);
|
||||
|
||||
__asm { /* tear down SEH. */
|
||||
mov eax,[esp]
|
||||
mov fs:[0], eax
|
||||
add esp, 8
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
*/
|
||||
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "../SDL_thread_c.h"
|
||||
|
||||
#if SDL_THREAD_WINDOWS
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include "SDL_thread.h"
|
||||
#include "../SDL_thread_c.h"
|
||||
|
||||
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
|
||||
static SDL_bool generic_local_storage = SDL_FALSE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue