Stack hint should look for 0, not -1, and not care about environment variables.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 26 May 2015 21:19:23 -0400
changeset 9649d7762e30ba24
parent 9648 e6bf740c92f8
child 9650 12d477422f47
Stack hint should look for 0, not -1, and not care about environment variables.
include/SDL_hints.h
src/SDL.c
src/thread/pthread/SDL_systhread.c
test/torturethread.c
     1.1 --- a/include/SDL_hints.h	Tue May 26 21:13:27 2015 -0400
     1.2 +++ b/include/SDL_hints.h	Tue May 26 21:19:23 2015 -0400
     1.3 @@ -350,13 +350,12 @@
     1.4  
     1.5  
     1.6  /**
     1.7 -*  \brief  A string specifying SDL's threads stack size in bytes or "-1" for the backend's default size
     1.8 +*  \brief  A string specifying SDL's threads stack size in bytes or "0" for the backend's default size
     1.9  *
    1.10  *  Use this hint in case you need to set SDL's threads stack size to other than the default.
    1.11  *  This is specially useful if you build SDL against a non glibc libc library (such as musl) which
    1.12  *  provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses).
    1.13  *  Support for this hint is currenly available only in the pthread backend.
    1.14 -*  As a precaution, this hint can not be set via an environment variable.
    1.15  */
    1.16  #define SDL_HINT_THREAD_STACK_SIZE              "SDL_THREAD_STACK_SIZE"
    1.17  
     2.1 --- a/src/SDL.c	Tue May 26 21:13:27 2015 -0400
     2.2 +++ b/src/SDL.c	Tue May 26 21:19:23 2015 -0400
     2.3 @@ -107,7 +107,6 @@
     2.4  int
     2.5  SDL_InitSubSystem(Uint32 flags)
     2.6  {
     2.7 -    static Uint32 hints_initialized = SDL_FALSE;
     2.8      if (!SDL_MainIsReady) {
     2.9          SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");
    2.10          return -1;
    2.11 @@ -115,13 +114,6 @@
    2.12  
    2.13      /* Clear the error message */
    2.14      SDL_ClearError();
    2.15 -    
    2.16 -    if (hints_initialized == SDL_FALSE) {
    2.17 -        /* Set a default of -1 for SDL_HINT_THREAD_STACK_SIZE to prevent the
    2.18 -           end user from interfering it's value with environment variables */
    2.19 -        SDL_SetHintWithPriority(SDL_HINT_THREAD_STACK_SIZE, "-1", SDL_HINT_OVERRIDE);
    2.20 -        hints_initialized = SDL_TRUE;
    2.21 -    }
    2.22  
    2.23  #if SDL_VIDEO_DRIVER_WINDOWS
    2.24  	if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
     3.1 --- a/src/thread/pthread/SDL_systhread.c	Tue May 26 21:13:27 2015 -0400
     3.2 +++ b/src/thread/pthread/SDL_systhread.c	Tue May 26 21:19:23 2015 -0400
     3.3 @@ -111,7 +111,10 @@
     3.4      
     3.5      /* If the SDL_HINT_THREAD_STACK_SIZE exists and it seems to be a positive number, use it */
     3.6      if (hint && hint[0] >= '0' && hint[0] <= '9') {
     3.7 -        pthread_attr_setstacksize(&type, (size_t)SDL_atoi(hint));
     3.8 +        const size_t stacksize = (size_t) SDL_atoi(hint);
     3.9 +        if (stacksize > 0) {
    3.10 +            pthread_attr_setstacksize(&type, );
    3.11 +        }
    3.12      }
    3.13      
    3.14      pthread_attr_getstacksize(&type, &ss);
     4.1 --- a/test/torturethread.c	Tue May 26 21:13:27 2015 -0400
     4.2 +++ b/test/torturethread.c	Tue May 26 21:19:23 2015 -0400
     4.3 @@ -87,8 +87,6 @@
     4.4          SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
     4.5          return (1);
     4.6      }
     4.7 -    
     4.8 -    SDL_SetHintWithPriority(SDL_HINT_THREAD_STACK_SIZE, SDL_getenv(SDL_HINT_THREAD_STACK_SIZE), SDL_HINT_OVERRIDE);
     4.9  
    4.10      signal(SIGSEGV, SIG_DFL);
    4.11      for (i = 0; i < NUMTHREADS; i++) {