[Mesa-dev] [PATCH] c11/threads: Use PTHREAD_MUTEX_RECURSIVE by default
Felix Janda
felix.janda at posteo.de
Sat Jan 31 10:26:15 PST 2015
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. This makes
mesa compile with musl libc.
---
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
More information about the mesa-dev
mailing list