Use pthread_mutex for global lock on Linux.
authorJosh Gargus <jjosh@google.com>
Thu, 6 Oct 2016 01:32:51 +0000 (18:32 -0700)
committerJosh Gargus <jjosh@google.com>
Thu, 6 Oct 2016 01:32:51 +0000 (18:32 -0700)
glslang/OSDependent/Unix/ossource.cpp

index 8e583ea..0e6d730 100644 (file)
@@ -165,11 +165,12 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
                return false;
 }
 
-// TODO: non-windows: if we need these on linux, flesh them out
-void InitGlobalLock() { }
-void GetGlobalLock() { }
-void ReleaseGlobalLock() { }
+static pthread_mutex_t gMutex;
+void InitGlobalLock() { pthread_mutex_init(&gMutex, NULL); }
+void GetGlobalLock() { pthread_mutex_lock(&gMutex); }
+void ReleaseGlobalLock() { pthread_mutex_unlock(&gMutex); }
 
+// TODO: non-windows: if we need these on linux, flesh them out
 void* OS_CreateThread(TThreadEntrypoint /*entry*/)
 {
     return 0;