Commit 15c4fb2a authored by Ryan C. Gordon's avatar Ryan C. Gordon

Clean up the win32 compiler warnings for SDL threads, in the 1.3 branch.

--HG--
extra : rebase_source : 420916ed06d79e2d3c1d50e5fb40314ac7d94d85
parent d1cc70ba
...@@ -90,17 +90,6 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); ...@@ -90,17 +90,6 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
#include <process.h> /* This has _beginthread() and _endthread() defined! */ #include <process.h> /* This has _beginthread() and _endthread() defined! */
#endif #endif
#ifdef __GNUC__
typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned
(__stdcall *
func) (void *),
void *arg,
unsigned,
unsigned
*threadID);
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#else
typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned (__stdcall * unsigned (__stdcall *
func) (void func) (void
...@@ -108,7 +97,6 @@ typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, ...@@ -108,7 +97,6 @@ typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
void *arg, unsigned, void *arg, unsigned,
unsigned *threadID); unsigned *threadID);
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#endif
/** /**
* Create a thread. * Create a thread.
......
...@@ -33,16 +33,13 @@ ...@@ -33,16 +33,13 @@
#include <process.h> #include <process.h>
#endif #endif
#if __GNUC__ /* Cygwin gcc-3 ... MingW64 (even with a i386 host) does this like MSVC. */
typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, #if (defined(__MINGW32__) && (__GNUC__ < 4))
unsigned typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
(__stdcall * unsigned (__stdcall *func)(void *), void *arg,
func) (void *), unsigned, unsigned *threadID);
void *arg, typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
unsigned,
unsigned
*threadID);
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
/* This is for Watcom targets except OS2 */ /* This is for Watcom targets except OS2 */
#if __WATCOMC__ < 1240 #if __WATCOMC__ < 1240
...@@ -59,6 +56,7 @@ typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *, ...@@ -59,6 +56,7 @@ typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *,
unsigned unsigned
*threadID); *threadID);
typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code); typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code);
#else #else
typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
unsigned (__stdcall * unsigned (__stdcall *
...@@ -77,7 +75,7 @@ typedef struct ThreadStartParms ...@@ -77,7 +75,7 @@ typedef struct ThreadStartParms
pfnSDL_CurrentEndThread pfnCurrentEndThread; pfnSDL_CurrentEndThread pfnCurrentEndThread;
} tThreadStartParms, *pThreadStartParms; } tThreadStartParms, *pThreadStartParms;
static unsigned __stdcall static DWORD
RunThread(void *data) RunThread(void *data)
{ {
pThreadStartParms pThreadParms = (pThreadStartParms) data; pThreadStartParms pThreadParms = (pThreadStartParms) data;
...@@ -97,6 +95,18 @@ RunThread(void *data) ...@@ -97,6 +95,18 @@ RunThread(void *data)
return (0); return (0);
} }
static DWORD WINAPI
RunThreadViaCreateThread(LPVOID data)
{
return RunThread(data);
}
static unsigned __stdcall
RunThreadViaBeginThreadEx(void *data)
{
return (unsigned) RunThread(data);
}
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
int int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args, SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
...@@ -115,7 +125,6 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) ...@@ -115,7 +125,6 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
#endif #endif
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
DWORD threadid = 0;
pThreadStartParms pThreadParms = pThreadStartParms pThreadParms =
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
if (!pThreadParms) { if (!pThreadParms) {
...@@ -128,12 +137,14 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) ...@@ -128,12 +137,14 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
pThreadParms->args = args; pThreadParms->args = args;
if (pfnBeginThread) { if (pfnBeginThread) {
thread->handle = unsigned threadid = 0;
(SYS_ThreadHandle) pfnBeginThread(NULL, 0, RunThread, thread->handle = (SYS_ThreadHandle)
pThreadParms, 0, &threadid); ((size_t) pfnBeginThread(NULL, 0, RunThreadViaBeginThreadEx,
pThreadParms, 0, &threadid));
} else { } else {
thread->handle = DWORD threadid = 0;
CreateThread(NULL, 0, RunThread, pThreadParms, 0, &threadid); thread->handle = CreateThread(NULL, 0, RunThreadViaCreateThread,
pThreadParms, 0, &threadid);
} }
if (thread->handle == NULL) { if (thread->handle == NULL) {
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment