threads: Handle SDL_HINT_THREAD_STACK_SIZE at top level, implement elsewhere.
This commit is contained in:
parent
8b65d225e8
commit
7ae2951fca
6 changed files with 68 additions and 18 deletions
|
@ -45,7 +45,6 @@
|
|||
|
||||
#include "SDL_platform.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_thread_c.h"
|
||||
#include "../SDL_systhread.h"
|
||||
#ifdef __ANDROID__
|
||||
|
@ -87,7 +86,6 @@ int
|
|||
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
||||
{
|
||||
pthread_attr_t type;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_THREAD_STACK_SIZE);
|
||||
|
||||
/* do this here before any threads exist, so there's no race condition. */
|
||||
#if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
|
||||
|
@ -108,12 +106,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
|
|||
}
|
||||
pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
/* If the SDL_HINT_THREAD_STACK_SIZE exists and it seems to be a positive number, use it */
|
||||
if (hint && hint[0] >= '0' && hint[0] <= '9') {
|
||||
const size_t stacksize = (size_t) SDL_atoi(hint);
|
||||
if (stacksize > 0) {
|
||||
pthread_attr_setstacksize(&type, stacksize);
|
||||
}
|
||||
/* Set caller-requested stack size. Otherwise: use the system default. */
|
||||
if (thread->stacksize) {
|
||||
pthread_attr_setstacksize(&type, (size_t) thread->stacksize);
|
||||
}
|
||||
|
||||
/* Create the thread and go! */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue