Merge branch 'mc/maint-zoneparse' into maint
[gitweb.git] / thread-utils.c
index 55e7e2904eb5f95cedaec2520ddd1d158ee93c7a..589f838f82b568195232ea81346d0049261b86b1 100644 (file)
@@ -1,9 +1,7 @@
 #include "cache.h"
+#include <pthread.h>
 
-#ifdef _WIN32
-#  define WIN32_LEAN_AND_MEAN
-#  include <windows.h>
-#elif defined(hpux) || defined(__hpux) || defined(_hpux)
+#if defined(hpux) || defined(__hpux) || defined(_hpux)
 #  include <sys/pstat.h>
 #endif
 
@@ -46,3 +44,18 @@ int online_cpus(void)
 
        return 1;
 }
+
+int init_recursive_mutex(pthread_mutex_t *m)
+{
+       pthread_mutexattr_t a;
+       int ret;
+
+       ret = pthread_mutexattr_init(&a);
+       if (!ret) {
+               ret = pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE);
+               if (!ret)
+                       ret = pthread_mutex_init(m, &a);
+               pthread_mutexattr_destroy(&a);
+       }
+       return ret;
+}