| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | */ |
| | | typedef int (SDLCALL * SDL_ThreadFunction) (void *data); |
| | | |
| | | #if defined(__WIN32__) && !defined(HAVE_LIBC) |
| | | #if defined(__WIN32__) |
| | | /** |
| | | * \file SDL_thread.h |
| | | * |
| | |
| | | void * /*arg*/, unsigned, unsigned * /* threadID */); |
| | | 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. |
| | | */ |
| | |
| | | */ |
| | | #if defined(SDL_CreateThread) && SDL_DYNAMIC_API |
| | | #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 |
| | | #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 |
| | | #define SDL_CreateThread(fn, name, data) SDL_CreateThread(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)_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)SDL_endthread) |
| | | #endif |
| | | |
| | | #elif defined(__OS2__) |
| | |
| | | * into a dll with Watcom's runtime statically linked. |
| | | */ |
| | | #define SDL_PASSED_BEGINTHREAD_ENDTHREAD |
| | | |
| | | #ifndef __EMX__ |
| | | #include <process.h> |
| | | #else |
| | | #include <stdlib.h> |
| | | #endif |
| | | |
| | | typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/); |
| | | 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 |
| | | SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, |
| | | pfnSDL_CurrentBeginThread pfnBeginThread, |
| | |
| | | SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data, |
| | | pfnSDL_CurrentBeginThread pfnBeginThread, |
| | | pfnSDL_CurrentEndThread pfnEndThread); |
| | | |
| | | #if defined(SDL_CreateThread) && SDL_DYNAMIC_API |
| | | #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 |
| | | #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 |
| | | #define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread) |
| | | #define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, 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)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) |
| | | #endif |
| | | |
| | | #else |