Browse Source

Fixed Linux build. Made pthreads mutexes recursive.

Lasse Öörni 14 years ago
parent
commit
f47dac9269

+ 6 - 2
Engine/Core/Mutex.cpp

@@ -60,7 +60,11 @@ void Mutex::Release()
 Mutex::Mutex() :
 Mutex::Mutex() :
     criticalSection_(new pthread_mutex_t)
     criticalSection_(new pthread_mutex_t)
 {
 {
-    pthread_mutex_init((pthread_mutex_t*)criticalSection_);
+    pthread_mutex_t* mutex = (pthread_mutex_t*)criticalSection_;
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(mutex, &attr);
 }
 }
 
 
 Mutex::~Mutex()
 Mutex::~Mutex()
@@ -78,7 +82,7 @@ void Mutex::Acquire()
 
 
 void Mutex::Release()
 void Mutex::Release()
 {
 {
-    pthread_mutex_acquire((pthread_mutex_t*)criticalSection_);
+    pthread_mutex_unlock((pthread_mutex_t*)criticalSection_);
 }
 }
 #endif
 #endif
 
 

+ 1 - 0
Engine/Core/ProcessUtils.cpp

@@ -26,6 +26,7 @@
 #include "ProcessUtils.h"
 #include "ProcessUtils.h"
 
 
 #include <cstdio>
 #include <cstdio>
+#include <cstdlib>
 #include <fcntl.h>
 #include <fcntl.h>
 
 
 #ifdef _WIN32
 #ifdef _WIN32

+ 4 - 7
Engine/Core/Thread.cpp

@@ -70,9 +70,9 @@ bool Thread::Start()
     #ifdef _WIN32
     #ifdef _WIN32
     handle_ = CreateThread(0, 0, ThreadFunctionStatic, this, 0, 0);
     handle_ = CreateThread(0, 0, ThreadFunctionStatic, this, 0, 0);
     #else
     #else
-    handle_ = new pthread_t;
-    pthread_attr_t type;
-    pthread_attr_init(&type);
+    handle_ = new pthread_t;
+    pthread_attr_t type;
+    pthread_attr_init(&type);
     pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
     pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
     pthread_create((pthread_t*)handle_, &type, ThreadFunctionStatic, this);
     pthread_create((pthread_t*)handle_, &type, ThreadFunctionStatic, this);
     #endif
     #endif
@@ -88,10 +88,7 @@ void Thread::Stop()
     #else
     #else
     pthread_t* thread = (pthread_t*)handle_;
     pthread_t* thread = (pthread_t*)handle_;
     if (thread)
     if (thread)
-    {
-        pthread_join(thread, 0);
-        pthread_destroy(thread);
-    }
+        pthread_join(*thread, 0);
     delete thread;
     delete thread;
     #endif
     #endif
     handle_ = 0;
     handle_ = 0;

+ 4 - 0
ThirdParty/GLFW/include/GL/glfw.h

@@ -27,6 +27,8 @@
  *
  *
  *************************************************************************/
  *************************************************************************/
 
 
+// Modified by Lasse Öörni for Urho3D
+
 #ifndef __glfw_h_
 #ifndef __glfw_h_
 #define __glfw_h_
 #define __glfw_h_
 
 
@@ -159,6 +161,8 @@ extern "C" {
  * special defines which normally requires the user to include <windows.h>
  * special defines which normally requires the user to include <windows.h>
  * (which is not a nice solution for portable programs).
  * (which is not a nice solution for portable programs).
  */
  */
+#define GLFW_NO_GLU
+
 #if defined(__APPLE_CC__)
 #if defined(__APPLE_CC__)
  #include <OpenGL/gl.h>
  #include <OpenGL/gl.h>
  #ifndef GLFW_NO_GLU
  #ifndef GLFW_NO_GLU