X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=thread-utils.c;h=589f838f82b568195232ea81346d0049261b86b1;hb=c7e375de4228cdb86e2582e2eda7fa3a6f352fc2;hp=55e7e2904eb5f95cedaec2520ddd1d158ee93c7a;hpb=267123b4299ea2c2f090ef169f9fc5039897cd72;p=git.git diff --git a/thread-utils.c b/thread-utils.c index 55e7e2904..589f838f8 100644 --- a/thread-utils.c +++ b/thread-utils.c @@ -1,9 +1,7 @@ #include "cache.h" +#include -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -#elif defined(hpux) || defined(__hpux) || defined(_hpux) +#if defined(hpux) || defined(__hpux) || defined(_hpux) # include #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; +}