mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Make it possible for the application to use different C runtime begin/end thread functions
This commit is contained in:
parent
9feabd351c
commit
232b7feef6
@ -93,11 +93,18 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
|||||||
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||||
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
||||||
|
|
||||||
typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread)
|
typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread)
|
||||||
(void *, unsigned, unsigned (__stdcall *func)(void *),
|
(void *, unsigned, unsigned (__stdcall *func)(void *),
|
||||||
void * /*arg*/, unsigned, unsigned * /* threadID */);
|
void * /*arg*/, unsigned, unsigned * /* threadID */);
|
||||||
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
|
||||||
|
|
||||||
|
#ifndef SDL_beginthread
|
||||||
|
#define SDL_beginthread _beginthreadex
|
||||||
|
#endif
|
||||||
|
#ifndef SDL_endthread
|
||||||
|
#define SDL_endthread _endthreadex
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a thread.
|
* Create a thread.
|
||||||
*/
|
*/
|
||||||
@ -118,12 +125,12 @@ SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|||||||
*/
|
*/
|
||||||
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
||||||
#undef SDL_CreateThread
|
#undef SDL_CreateThread
|
||||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#undef SDL_CreateThreadWithStackSize
|
#undef SDL_CreateThreadWithStackSize
|
||||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#else
|
#else
|
||||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
@ -132,13 +139,23 @@ SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|||||||
* into a dll with Watcom's runtime statically linked.
|
* into a dll with Watcom's runtime statically linked.
|
||||||
*/
|
*/
|
||||||
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
#define SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
||||||
|
|
||||||
#ifndef __EMX__
|
#ifndef __EMX__
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
|
typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/);
|
||||||
typedef void (*pfnSDL_CurrentEndThread)(void);
|
typedef void (*pfnSDL_CurrentEndThread)(void);
|
||||||
|
|
||||||
|
#ifndef SDL_beginthread
|
||||||
|
#define SDL_beginthread _beginthread
|
||||||
|
#endif
|
||||||
|
#ifndef SDL_endthread
|
||||||
|
#define SDL_endthread _endthread
|
||||||
|
#endif
|
||||||
|
|
||||||
extern DECLSPEC SDL_Thread *SDLCALL
|
extern DECLSPEC SDL_Thread *SDLCALL
|
||||||
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
||||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||||
@ -147,14 +164,15 @@ extern DECLSPEC SDL_Thread *SDLCALL
|
|||||||
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
|
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
|
||||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||||
pfnSDL_CurrentEndThread pfnEndThread);
|
pfnSDL_CurrentEndThread pfnEndThread);
|
||||||
|
|
||||||
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
||||||
#undef SDL_CreateThread
|
#undef SDL_CreateThread
|
||||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#undef SDL_CreateThreadWithStackSize
|
#undef SDL_CreateThreadWithStackSize
|
||||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#else
|
#else
|
||||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user