Merge pull request #539 from schwa423/linux_global_lock
Use pthread_mutex for global lock on Linux.
diff --git a/glslang/OSDependent/Unix/ossource.cpp b/glslang/OSDependent/Unix/ossource.cpp
index 8e583ea..7e84d4e 100644
--- a/glslang/OSDependent/Unix/ossource.cpp
+++ b/glslang/OSDependent/Unix/ossource.cpp
@@ -165,11 +165,29 @@
return false;
}
-// TODO: non-windows: if we need these on linux, flesh them out
-void InitGlobalLock() { }
-void GetGlobalLock() { }
-void ReleaseGlobalLock() { }
+namespace {
+pthread_mutex_t gMutex;
+}
+void InitGlobalLock()
+{
+ pthread_mutexattr_t mutexattr;
+ pthread_mutexattr_init(&mutexattr);
+ pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&gMutex, &mutexattr);
+}
+
+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;