OS/2 port!
This was mostly, if not entirely, written by "Doodle" and "Caetano": doodle@scenergy.dfmk.hu daniel@caetano.eng.br --ryan. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401193
This commit is contained in:
parent
c154edb92f
commit
b08452cb40
49 changed files with 6571 additions and 8 deletions
|
@ -50,7 +50,50 @@ struct SDL_Thread;
|
|||
typedef struct SDL_Thread SDL_Thread;
|
||||
|
||||
/* Create a thread */
|
||||
#ifdef __OS2__
|
||||
/*
|
||||
We compile SDL into a DLL on OS/2. This means, that it's the DLL which
|
||||
creates a new thread for the calling process with the SDL_CreateThread()
|
||||
API. There is a problem with this, that only the RTL of the SDL.DLL will
|
||||
be initialized for those threads, and not the RTL of the calling application!
|
||||
To solve this, we make a little hack here.
|
||||
We'll always use the caller's _beginthread() and _endthread() APIs to
|
||||
start a new thread. This way, it it's the SDL.DLL which uses this API,
|
||||
then the RTL of SDL.DLL will be used to create the new thread, and if it's
|
||||
the application, then the RTL of the application will be used.
|
||||
So, in short:
|
||||
Always use the _beginthread() and _endthread() of the calling runtime library!
|
||||
*/
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <process.h> // This has _beginthread() and _endthread() defined!
|
||||
#endif
|
||||
#ifdef __EMX__
|
||||
#include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used!
|
||||
#endif
|
||||
|
||||
typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam);
|
||||
typedef void SDLCALL (*pfnSDL_CurrentEndThread)(void);
|
||||
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
// Disable warnings about unreferenced symbol!
|
||||
#pragma disable_message (202)
|
||||
static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam)
|
||||
{
|
||||
return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam);
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_CurrentEndThread(void)
|
||||
{
|
||||
_endthread();
|
||||
}
|
||||
|
||||
#define SDL_CreateThread(fn, data) SDL_CreateThread_Core(fn, data, SDL_CurrentBeginThread, SDL_CurrentEndThread)
|
||||
|
||||
#else
|
||||
extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data);
|
||||
#endif
|
||||
|
||||
/* Get the 32-bit thread identifier for the current thread */
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue