diff options
author | Jason Evans <jasone@canonware.com> | 2016-11-17 23:14:57 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-11-17 23:16:27 (GMT) |
commit | 949a27fc329e6a55a94857a401765d017f13f8ff (patch) | |
tree | 16edfdcad26793da9e87639ab05f014c864480c1 | |
parent | 62f2d84e7aebaa25df32a0ae882cc856e5218687 (diff) | |
download | jemalloc-949a27fc329e6a55a94857a401765d017f13f8ff.zip jemalloc-949a27fc329e6a55a94857a401765d017f13f8ff.tar.gz jemalloc-949a27fc329e6a55a94857a401765d017f13f8ff.tar.bz2 |
Add pthread_atfork(3) feature test.
Some versions of Android provide a pthreads library without providing
pthread_atfork(), so in practice a separate feature test is necessary
for the latter.
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | include/jemalloc/internal/jemalloc_internal_defs.h.in | 3 | ||||
-rw-r--r-- | src/jemalloc.c | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 68602e1..197414c 100644 --- a/configure.ac +++ b/configure.ac @@ -1329,6 +1329,14 @@ if test "x$abi" != "xpecoff" ; then AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], [AC_SEARCH_LIBS([pthread_create], , , AC_MSG_ERROR([libpthread is missing]))]) + JE_COMPILABLE([pthread_atfork(3)], [ +#include <pthread.h> +], [ + pthread_atfork((void *)0, (void *)0, (void *)0); +], [je_cv_pthread_atfork]) + if test "x${je_cv_pthread_atfork}" = "xyes" ; then + AC_DEFINE([JEMALLOC_HAVE_PTHREAD_ATFORK], [ ]) + fi fi CPPFLAGS="$CPPFLAGS -D_REENTRANT" diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h.in b/include/jemalloc/internal/jemalloc_internal_defs.h.in index 5419513..d530119 100644 --- a/include/jemalloc/internal/jemalloc_internal_defs.h.in +++ b/include/jemalloc/internal/jemalloc_internal_defs.h.in @@ -79,6 +79,9 @@ */ #undef JEMALLOC_HAVE_ISSETUGID +/* Defined if pthread_atfork(3) is available. */ +#undef JEMALLOC_HAVE_PTHREAD_ATFORK + /* * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available. */ diff --git a/src/jemalloc.c b/src/jemalloc.c index 14c1c4d..baead66 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1411,8 +1411,9 @@ malloc_init_hard_recursible(void) ncpus = malloc_ncpus(); -#if (!defined(JEMALLOC_MUTEX_INIT_CB) && !defined(JEMALLOC_ZONE) \ - && !defined(_WIN32) && !defined(__native_client__)) +#if (defined(JEMALLOC_HAVE_PTHREAD_ATFORK) && !defined(JEMALLOC_MUTEX_INIT_CB) \ + && !defined(JEMALLOC_ZONE) && !defined(_WIN32) && \ + !defined(__native_client__)) /* LinuxThreads' pthread_atfork() allocates. */ if (pthread_atfork(jemalloc_prefork, jemalloc_postfork_parent, jemalloc_postfork_child) != 0) { |