Mercurial > sdl-ios-xcode
comparison include/SDL_thread.h @ 1190:173c063d4f55
OS/2 port!
This was mostly, if not entirely, written by "Doodle" and "Caetano":
doodle@scenergy.dfmk.hu
daniel@caetano.eng.br
--ryan.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 23 Nov 2005 07:29:56 +0000 |
parents | 02759105b989 |
children | c9b51268668f |
comparison
equal
deleted
inserted
replaced
1189:c96b326b90ba | 1190:173c063d4f55 |
---|---|
48 /* The SDL thread structure, defined in SDL_thread.c */ | 48 /* The SDL thread structure, defined in SDL_thread.c */ |
49 struct SDL_Thread; | 49 struct SDL_Thread; |
50 typedef struct SDL_Thread SDL_Thread; | 50 typedef struct SDL_Thread SDL_Thread; |
51 | 51 |
52 /* Create a thread */ | 52 /* Create a thread */ |
53 #ifdef __OS2__ | |
54 /* | |
55 We compile SDL into a DLL on OS/2. This means, that it's the DLL which | |
56 creates a new thread for the calling process with the SDL_CreateThread() | |
57 API. There is a problem with this, that only the RTL of the SDL.DLL will | |
58 be initialized for those threads, and not the RTL of the calling application! | |
59 To solve this, we make a little hack here. | |
60 We'll always use the caller's _beginthread() and _endthread() APIs to | |
61 start a new thread. This way, it it's the SDL.DLL which uses this API, | |
62 then the RTL of SDL.DLL will be used to create the new thread, and if it's | |
63 the application, then the RTL of the application will be used. | |
64 So, in short: | |
65 Always use the _beginthread() and _endthread() of the calling runtime library! | |
66 */ | |
67 | |
68 #ifdef __WATCOMC__ | |
69 #include <process.h> // This has _beginthread() and _endthread() defined! | |
70 #endif | |
71 #ifdef __EMX__ | |
72 #include <stdlib.h> // This has _beginthread() and _endthread() defined, if -Zmt flag is used! | |
73 #endif | |
74 | |
75 typedef Uint32 SDLCALL (*pfnSDL_CurrentBeginThread)(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam); | |
76 typedef void SDLCALL (*pfnSDL_CurrentEndThread)(void); | |
77 | |
78 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread_Core(int (*fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); | |
79 | |
80 // Disable warnings about unreferenced symbol! | |
81 #pragma disable_message (202) | |
82 static Uint32 SDLCALL SDL_CurrentBeginThread(void (*pfnThreadFn)(void *), Uint32 uiStackSize, void *pParam) | |
83 { | |
84 return _beginthread(pfnThreadFn, NULL, uiStackSize, pParam); | |
85 } | |
86 | |
87 static void SDLCALL SDL_CurrentEndThread(void) | |
88 { | |
89 _endthread(); | |
90 } | |
91 | |
92 #define SDL_CreateThread(fn, data) SDL_CreateThread_Core(fn, data, SDL_CurrentBeginThread, SDL_CurrentEndThread) | |
93 | |
94 #else | |
53 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); | 95 extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); |
96 #endif | |
54 | 97 |
55 /* Get the 32-bit thread identifier for the current thread */ | 98 /* Get the 32-bit thread identifier for the current thread */ |
56 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); | 99 extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); |
57 | 100 |
58 /* Get the 32-bit thread identifier for the specified thread, | 101 /* Get the 32-bit thread identifier for the specified thread, |