summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--OpenAL32/Include/alMain.h7
-rw-r--r--config.h.in3
3 files changed, 13 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f2af7e7f..f1c38727 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -167,6 +167,9 @@ IF(NOT HAVE_WINDOWS_H)
MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
ENDIF()
+ # Some systems need pthread_np.h to get recursive mutexes
+ CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
+
# _GNU_SOURCE is needed on some systems for extra attributes, and
# _REENTRANT is needed for libc thread-safety
ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_REENTRANT)
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 98d84a18..6bc5fd48 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -17,6 +17,9 @@
#include <assert.h>
#include <pthread.h>
+#ifdef HAVE_PTHREAD_NP_H
+#include <pthread_np.h>
+#endif
#include <sys/time.h>
#include <time.h>
#include <errno.h>
@@ -45,6 +48,10 @@ static inline void InitializeCriticalSection(CRITICAL_SECTION *cs)
assert(ret == 0);
ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE);
+#ifdef HAVE_PTHREAD_NP_H
+ if(ret != 0)
+ ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE);
+#endif
assert(ret == 0);
ret = pthread_mutex_init(cs, &attrib);
assert(ret == 0);
diff --git a/config.h.in b/config.h.in
index 5890b6fd..f40ca8a9 100644
--- a/config.h.in
+++ b/config.h.in
@@ -46,4 +46,7 @@
/* Define if we have GCC's destructor attribute */
#cmakedefine HAVE_GCC_DESTRUCTOR
+/* Define if we have pthread_np.h */
+#cmakedefine HAVE_PTHREAD_NP_H
+
#endif