Fixed bug 2076 - OpenGL doesn't work with --disable-threads
authorSam Lantinga <slouken@libsdl.org>
Thu, 05 Sep 2013 07:15:26 -0700
changeset 7730e928464b98ec
parent 7729 384d5ba7ee44
child 7731 9cbe58c01e31
Fixed bug 2076 - OpenGL doesn't work with --disable-threads

stepik-777

Thread local storage is used to store current window and current opengl context. OpenGL worked before this changeset: 7596 (45e5c263c096)
src/thread/SDL_systhread.h
src/thread/SDL_thread.c
src/thread/SDL_thread_c.h
     1.1 --- a/src/thread/SDL_systhread.h	Thu Sep 05 07:02:27 2013 -0700
     1.2 +++ b/src/thread/SDL_systhread.h	Thu Sep 05 07:15:26 2013 -0700
     1.3 @@ -26,6 +26,7 @@
     1.4  #define _SDL_systhread_h
     1.5  
     1.6  #include "SDL_thread.h"
     1.7 +#include "SDL_thread_c.h"
     1.8  
     1.9  /* This function creates a thread, passing args to SDL_RunThread(),
    1.10     saves a system-dependent thread id in thread->id, and returns 0
     2.1 --- a/src/thread/SDL_thread.c	Thu Sep 05 07:02:27 2013 -0700
     2.2 +++ b/src/thread/SDL_thread.c	Thu Sep 05 07:15:26 2013 -0700
     2.3 @@ -125,6 +125,7 @@
     2.4      SDL_TLSEntry *entry;
     2.5      SDL_TLSData *storage = NULL;
     2.6  
     2.7 +#if !SDL_THREADS_DISABLED
     2.8      if (!SDL_generic_TLS_mutex) {
     2.9          static SDL_SpinLock tls_lock;
    2.10          SDL_AtomicLock(&tls_lock);
    2.11 @@ -139,6 +140,7 @@
    2.12          }
    2.13          SDL_AtomicUnlock(&tls_lock);
    2.14      }
    2.15 +#endif /* SDL_THREADS_DISABLED */
    2.16  
    2.17      SDL_MemoryBarrierAcquire();
    2.18      SDL_LockMutex(SDL_generic_TLS_mutex);
    2.19 @@ -148,7 +150,9 @@
    2.20              break;
    2.21          }
    2.22      }
    2.23 +#if !SDL_THREADS_DISABLED
    2.24      SDL_UnlockMutex(SDL_generic_TLS_mutex);
    2.25 +#endif
    2.26  
    2.27      return storage;
    2.28  }
     3.1 --- a/src/thread/SDL_thread_c.h	Thu Sep 05 07:02:27 2013 -0700
     3.2 +++ b/src/thread/SDL_thread_c.h	Thu Sep 05 07:15:26 2013 -0700
     3.3 @@ -23,6 +23,8 @@
     3.4  #ifndef _SDL_thread_c_h
     3.5  #define _SDL_thread_c_h
     3.6  
     3.7 +#include "SDL_thread.h"
     3.8 +
     3.9  /* Need the definitions of SYS_ThreadHandle */
    3.10  #if SDL_THREADS_DISABLED
    3.11  #include "generic/SDL_systhread_c.h"