From 4b942c5a070aab6ebe3296ca6c9ea511169280bd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 5 Sep 2013 07:15:26 -0700 Subject: [PATCH] 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 | 1 + src/thread/SDL_thread.c | 4 ++++ src/thread/SDL_thread_c.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/thread/SDL_systhread.h b/src/thread/SDL_systhread.h index 738ea27b0..36898f389 100644 --- a/src/thread/SDL_systhread.h +++ b/src/thread/SDL_systhread.h @@ -26,6 +26,7 @@ #define _SDL_systhread_h #include "SDL_thread.h" +#include "SDL_thread_c.h" /* This function creates a thread, passing args to SDL_RunThread(), saves a system-dependent thread id in thread->id, and returns 0 diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 5eaed0c0c..4b070dadc 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -125,6 +125,7 @@ SDL_Generic_GetTLSData() SDL_TLSEntry *entry; SDL_TLSData *storage = NULL; +#if !SDL_THREADS_DISABLED if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); @@ -139,6 +140,7 @@ SDL_Generic_GetTLSData() } SDL_AtomicUnlock(&tls_lock); } +#endif /* SDL_THREADS_DISABLED */ SDL_MemoryBarrierAcquire(); SDL_LockMutex(SDL_generic_TLS_mutex); @@ -148,7 +150,9 @@ SDL_Generic_GetTLSData() break; } } +#if !SDL_THREADS_DISABLED SDL_UnlockMutex(SDL_generic_TLS_mutex); +#endif return storage; } diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 1971ded24..c7b063e07 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -23,6 +23,8 @@ #ifndef _SDL_thread_c_h #define _SDL_thread_c_h +#include "SDL_thread.h" + /* Need the definitions of SYS_ThreadHandle */ #if SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h"