src/thread/win32/SDL_systhread.c
changeset 1471 9fb0eee04dd9
parent 1470 d47d96962fcc
child 1659 14717b52abc0
equal deleted inserted replaced
1470:d47d96962fcc 1471:9fb0eee04dd9
    28 
    28 
    29 #include "SDL_thread.h"
    29 #include "SDL_thread.h"
    30 #include "../SDL_thread_c.h"
    30 #include "../SDL_thread_c.h"
    31 #include "../SDL_systhread.h"
    31 #include "../SDL_systhread.h"
    32 
    32 
       
    33 #ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
       
    34 #ifndef _WIN32_WCE
       
    35 /* We'll use the C library from this DLL */
       
    36 #include <process.h>
       
    37 #endif
       
    38 
       
    39 #if __GNUC__
       
    40 typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
       
    41         unsigned (__stdcall *func)(void *), void *arg, 
       
    42         unsigned, unsigned *threadID);
       
    43 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
       
    44 #else
       
    45 typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
       
    46         unsigned (__stdcall *func)(void *), void *arg, 
       
    47         unsigned, unsigned *threadID);
       
    48 typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
       
    49 #endif
       
    50 #endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */
       
    51 
       
    52 
    33 typedef struct ThreadStartParms
    53 typedef struct ThreadStartParms
    34 {
    54 {
    35   void *args;
    55   void *args;
    36   pfnSDL_CurrentEndThread pfnCurrentEndThread;
    56   pfnSDL_CurrentEndThread pfnCurrentEndThread;
    37 } tThreadStartParms, *pThreadStartParms;
    57 } tThreadStartParms, *pThreadStartParms;
    54   if (pfnCurrentEndThread)
    74   if (pfnCurrentEndThread)
    55     (*pfnCurrentEndThread)(0);
    75     (*pfnCurrentEndThread)(0);
    56   return(0);
    76   return(0);
    57 }
    77 }
    58 
    78 
       
    79 #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
    59 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
    80 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread)
    60 {
    81 {
       
    82 #else
       
    83 int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
       
    84 {
       
    85 #ifdef _WIN32_WCE
       
    86 	pfnSDL_CurrentBeginThread pfnBeginThread = NULL;
       
    87 	pfnSDL_CurrentEndThread pfnEndThread = NULL;
       
    88 #else
       
    89 	pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex;
       
    90 	pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
       
    91 #endif
       
    92 #endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
    61 	unsigned threadid;
    93 	unsigned threadid;
    62 	pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms));
    94 	pThreadStartParms pThreadParms = (pThreadStartParms)SDL_malloc(sizeof(tThreadStartParms));
    63 	if (!pThreadParms) {
    95 	if (!pThreadParms) {
    64 		SDL_OutOfMemory();
    96 		SDL_OutOfMemory();
    65 		return(-1);
    97 		return(-1);