[PATCH] correctly detect adaptive mutexes in pthreads
Eric Wong
normalperson at yhbt.net
Sat Aug 30 23:29:16 PDT 2014
PTHREAD_MUTEX_ADAPTIVE_NP is an enum on glibc and not a macro,
we must test for their existence by attempting compilation.
---
Note: I have not benchmarked this, but I did test this by adding
a #warning in the #else branch.
If you prefer: git pull git://80x24.org/jemalloc dev
The following changes since commit 3ebf6db2c7fba746153cc67ca8fe6df7a886b8b8:
Merge pull request #108 from wqfish/dev (2014-08-27 12:04:01 -0700)
are available in the git repository at:
git://80x24.org/jemalloc dev
for you to fetch changes up to 579a7c567c157c2997140652d1955c6cdab350f4:
correctly detect adaptive mutexes in pthreads (2014-08-31 06:24:54 +0000)
----------------------------------------------------------------
Eric Wong (1):
correctly detect adaptive mutexes in pthreads
configure.ac | 12 ++++++++++++
include/jemalloc/internal/jemalloc_internal_defs.h.in | 3 +++
include/jemalloc/internal/mutex.h | 2 +-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 6f8fd3f..8e04b6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1371,6 +1371,18 @@ if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
fi
+JE_COMPILABLE([pthreads adaptive mutexes], [
+#include <pthread.h>
+], [
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
+ pthread_mutexattr_destroy(&attr);
+], [je_cv_pthread_mutex_adaptive_np])
+if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
+ AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
+fi
+
dnl ============================================================================
dnl Check for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in
index 955582e..fd85e5c 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h.in
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in
@@ -215,4 +215,7 @@
/* glibc memalign hook */
#undef JEMALLOC_GLIBC_MEMALIGN_HOOK
+/* adaptive mutex support in pthreads */
+#undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
+
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
diff --git a/include/jemalloc/internal/mutex.h b/include/jemalloc/internal/mutex.h
index de44e14..8a03d82 100644
--- a/include/jemalloc/internal/mutex.h
+++ b/include/jemalloc/internal/mutex.h
@@ -10,7 +10,7 @@ typedef struct malloc_mutex_s malloc_mutex_t;
#elif (defined(JEMALLOC_MUTEX_INIT_CB))
# define MALLOC_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, NULL}
#else
-# if (defined(PTHREAD_MUTEX_ADAPTIVE_NP) && \
+# if (defined(JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP) && \
defined(PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP))
# define MALLOC_MUTEX_TYPE PTHREAD_MUTEX_ADAPTIVE_NP
# define MALLOC_MUTEX_INITIALIZER {PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP}
--
EW
More information about the jemalloc-discuss
mailing list