|
@@ -26,6 +26,7 @@
|
|
|
#include "SDL_thread.h"
|
|
|
#include "SDL_thread_c.h"
|
|
|
#include "SDL_systhread.h"
|
|
|
+#include "SDL_hints.h"
|
|
|
#include "../SDL_error_c.h"
|
|
|
|
|
|
|
|
@@ -304,15 +305,15 @@ SDL_RunThread(void *data)
|
|
|
#endif
|
|
|
|
|
|
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
|
|
-DECLSPEC SDL_Thread *SDLCALL
|
|
|
-SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
- const char *name, void *data,
|
|
|
+static SDL_Thread *
|
|
|
+SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|
|
+ const char *name, const size_t stacksize, void *data,
|
|
|
pfnSDL_CurrentBeginThread pfnBeginThread,
|
|
|
pfnSDL_CurrentEndThread pfnEndThread)
|
|
|
#else
|
|
|
-DECLSPEC SDL_Thread *SDLCALL
|
|
|
-SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
- const char *name, void *data)
|
|
|
+static SDL_Thread *
|
|
|
+SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
|
|
+ const char *name, const size_t stacksize, void *data)
|
|
|
#endif
|
|
|
{
|
|
|
SDL_Thread *thread;
|
|
@@ -362,6 +363,8 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
+ thread->stacksize = stacksize;
|
|
|
+
|
|
|
/* Create the thread and go! */
|
|
|
#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
|
|
ret = SDL_SYS_CreateThread(thread, args, pfnBeginThread, pfnEndThread);
|
|
@@ -386,6 +389,40 @@ SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
return (thread);
|
|
|
}
|
|
|
|
|
|
+#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
|
|
+DECLSPEC SDL_Thread *SDLCALL
|
|
|
+SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
+ const char *name, void *data,
|
|
|
+ pfnSDL_CurrentBeginThread pfnBeginThread,
|
|
|
+ pfnSDL_CurrentEndThread pfnEndThread)
|
|
|
+#else
|
|
|
+DECLSPEC SDL_Thread *SDLCALL
|
|
|
+SDL_CreateThread(int (SDLCALL * fn) (void *),
|
|
|
+ const char *name, void *data)
|
|
|
+#endif
|
|
|
+{
|
|
|
+ /* !!! FIXME: in 2.1, just make stackhint part of the usual API. */
|
|
|
+ const char *stackhint = SDL_GetHint(SDL_HINT_THREAD_STACK_SIZE);
|
|
|
+ size_t stacksize = 0;
|
|
|
+
|
|
|
+ /* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */
|
|
|
+ if (stackhint != NULL) {
|
|
|
+ char *endp = NULL;
|
|
|
+ const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10);
|
|
|
+ if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */
|
|
|
+ if (hintval > 0) { /* reject bogus values. */
|
|
|
+ stacksize = (size_t) hintval;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD
|
|
|
+ return SDL_CreateThreadWithStackSize(fn, name, stacksize, data, pfnBeginThread, pfnEndThread);
|
|
|
+#else
|
|
|
+ return SDL_CreateThreadWithStackSize(fn, name, stacksize, data);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
SDL_threadID
|
|
|
SDL_GetThreadID(SDL_Thread * thread)
|
|
|
{
|