From 3a5b98e8aff8fc4d56350d84adaed26f7d609b74 Mon Sep 17 00:00:00 2001 From: Felix Janda Date: Sat, 17 Jan 2015 15:19:34 +0100 Subject: [PATCH] c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default Previously PTHREAD_MUTEX_RECURSIVE_NP had been used on linux for compatibility with old glibc. Now fall back to the nonstandard version only if the standard version is not defined. --- include/c11/threads_posix.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h index f9c165d..e0b0653 100644 --- a/include/c11/threads_posix.h +++ b/include/c11/threads_posix.h @@ -61,6 +61,10 @@ Configuration macro: // FIXME: temporary non-standard hack to ease transition #define _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER +#ifndef PTHREAD_MUTEX_RECURSIVE +#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP +#endif + /*---------------------------- types ----------------------------*/ typedef pthread_cond_t cnd_t; typedef pthread_t thrd_t; @@ -177,13 +181,8 @@ mtx_init(mtx_t *mtx, int type) && type != (mtx_try|mtx_recursive)) return thrd_error; pthread_mutexattr_init(&attr); - if ((type & mtx_recursive) != 0) { -#if defined(__linux__) || defined(__linux) - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); -#else + if ((type & mtx_recursive) != 0) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#endif - } pthread_mutex_init(mtx, &attr); pthread_mutexattr_destroy(&attr); return thrd_success; -- 2.0.5