include/SDL_thread.h
changeset 1330 450721ad5436
parent 1312 c9b51268668f
child 1356 67114343400d
     1.1 --- a/include/SDL_thread.h	Sat Feb 04 22:01:44 2006 +0000
     1.2 +++ b/include/SDL_thread.h	Mon Feb 06 08:28:51 2006 +0000
     1.3 @@ -45,7 +45,7 @@
     1.4  typedef struct SDL_Thread SDL_Thread;
     1.5  
     1.6  /* Create a thread */
     1.7 -#ifdef __OS2__
     1.8 +#if defined(_WIN32) || defined(__OS2__)
     1.9  /*
    1.10     We compile SDL into a DLL on OS/2. This means, that it's the DLL which
    1.11     creates a new thread for the calling process with the SDL_CreateThread()
    1.12 @@ -53,39 +53,39 @@
    1.13     be initialized for those threads, and not the RTL of the calling application!
    1.14     To solve this, we make a little hack here.
    1.15     We'll always use the caller's _beginthread() and _endthread() APIs to
    1.16 -   start a new thread. This way, it it's the SDL.DLL which uses this API,
    1.17 +   start a new thread. This way, if it's the SDL.DLL which uses this API,
    1.18     then the RTL of SDL.DLL will be used to create the new thread, and if it's
    1.19     the application, then the RTL of the application will be used.
    1.20     So, in short:
    1.21     Always use the _beginthread() and _endthread() of the calling runtime library!
    1.22  */
    1.23 -
    1.24 -#ifdef __WATCOMC__
    1.25  #include <process.h> // This has _beginthread() and _endthread() defined!
    1.26 -#endif
    1.27  #ifdef __EMX__
    1.28  #include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
    1.29  #endif
    1.30  
    1.31 -typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam);
    1.32 -typedef void   SDLCALL (*pfnSDL_CurrentEndThread)(void);
    1.33 +#ifdef __OS2__
    1.34 +typedef int (__cdecl *pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); 
    1.35 +typedef void (__cdecl *pfnSDL_CurrentEndThread)(void);
    1.36 +#else
    1.37 +#ifdef __GNUC__
    1.38 +#include <stdint.h>
    1.39 +#endif
    1.40 +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned,
    1.41 +        unsigned (__stdcall *func)(void *), void *arg, 
    1.42 +        unsigned, unsigned *threadID);
    1.43 +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code);
    1.44 +#endif
    1.45  
    1.46 -extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
    1.47 +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
    1.48  
    1.49 -// Disable warnings about unreferenced symbol!
    1.50 -#pragma disable_message (202)
    1.51 -static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam)
    1.52 -{
    1.53 -  return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam);
    1.54 -}
    1.55 -
    1.56 -static void   SDLCALL SDL_CurrentEndThread(void)
    1.57 -{
    1.58 -  _endthread();
    1.59 -}
    1.60 -
    1.61 -#define SDL_CreateThread(fn, data) SDL_CreateThread_Core(fn, data, SDL_CurrentBeginThread, SDL_CurrentEndThread)
    1.62 -
    1.63 +#ifdef __OS2__
    1.64 +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
    1.65 +#elif defined(_WIN32_WCE)
    1.66 +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
    1.67 +#else
    1.68 +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
    1.69 +#endif
    1.70  #else
    1.71  extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
    1.72  #endif