 -    return 0;
 -}
 -
--
++#include <pthread.h>
++#ifdef HAVE_PTHREAD_NP_H
++#include <pthread_np.h>
++#endif
+ 
++#ifdef _WIN32
  void *LoadLib(const char *name)
  { return LoadLibraryA(name); }
  void CloseLib(void *handle)
-@@ -335,10 +303,6 @@ WCHAR *strdupW(const WCHAR *str)
+@@ -359,10 +328,6 @@ WCHAR *strdupW(const WCHAR *str)
  
  #else
  

From 428961aaa351425bc15011df633faba8d3ff246b Mon Sep 17 00:00:00 2001
From: Martin Herkt <lachs0r@srsfckn.biz>
Date: Sat, 7 Sep 2013 22:48:18 +0200
Subject: [PATCH] Require pthreads on Windows too

---
 Alc/helpers.c             | 44 ++++----------------------------------------
 CMakeLists.txt            | 45 ++++++++++++++++++++++-----------------------
 OpenAL32/Include/alMain.h | 15 +--------------
 3 files changed, 27 insertions(+), 77 deletions(-)

diff --git a/Alc/helpers.c b/Alc/helpers.c
index fe1318c..6d65354 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -265,44 +265,12 @@ void RestoreFPUMode(const FPUCtl *ctl)
 #endif
 }
 
+#include <pthread.h>
+#ifdef HAVE_PTHREAD_NP_H
+#include <pthread_np.h>
+#endif
 
 #ifdef _WIN32
-void pthread_once(pthread_once_t *once, void (*callback)(void))
-{
-    LONG ret;

-#include <pthread_np.h>
-#endif
 #include <sched.h>
 #include <time.h>
 #include <sys/time.h>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abd81fd..605b0ef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -384,6 +384,32 @@ IF(ALSOFT_DLOPEN)
     ENDIF()
 ENDIF()
 
+CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
+IF(NOT HAVE_PTHREAD_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)
+
+CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
+IF(HAVE_PTHREAD)
+    ADD_DEFINITIONS(-pthread)
+    SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -pthread")
+    SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
+ENDIF()
+
+CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
+IF(HAVE_LIBPTHREAD)
+    SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
+ENDIF()
+
+CHECK_SYMBOL_EXISTS(pthread_setschedparam pthread.h HAVE_PTHREAD_SETSCHEDPARAM)
+
+CHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
+IF(NOT HAVE_PTHREAD_SETNAME_NP)
+    CHECK_SYMBOL_EXISTS(pthread_set_name_np pthread.h HAVE_PTHREAD_SET_NAME_NP)
+ENDIF()
+
 # Check if we have Windows headers
 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501)
 IF(NOT HAVE_WINDOWS_H)
@@ -401,33 +427,6 @@ IF(NOT HAVE_WINDOWS_H)
         MESSAGE(FATAL_ERROR "No sleep function found!")
     ENDIF()
 
