Make background_thread not dependent on libdl.

When not using libdl, still allows background_thread to be enabled.
This commit is contained in:
Qi Wang 2018-06-07 12:28:40 -07:00 committed by Qi Wang
parent 1f55a15467
commit 2db2d2ef5e
2 changed files with 9 additions and 3 deletions

View File

@ -2130,8 +2130,7 @@ fi
dnl ============================================================================ dnl ============================================================================
dnl Enable background threads if possible. dnl Enable background threads if possible.
if test "x${have_pthread}" = "x1" -a "x${have_dlsym}" = "x1" \ if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" ; then
-a "x${je_cv_os_unfair_lock}" != "xyes" ; then
AC_DEFINE([JEMALLOC_BACKGROUND_THREAD]) AC_DEFINE([JEMALLOC_BACKGROUND_THREAD])
fi fi

View File

@ -27,7 +27,6 @@ background_thread_info_t *background_thread_info;
/******************************************************************************/ /******************************************************************************/
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER #ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
#include <dlfcn.h>
static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *, static int (*pthread_create_fptr)(pthread_t *__restrict, const pthread_attr_t *,
void *(*)(void *), void *__restrict); void *(*)(void *), void *__restrict);
@ -820,6 +819,10 @@ background_thread_stats_read(tsdn_t *tsdn, background_thread_stats_t *stats) {
#undef BILLION #undef BILLION
#undef BACKGROUND_THREAD_MIN_INTERVAL_NS #undef BACKGROUND_THREAD_MIN_INTERVAL_NS
#ifdef JEMALLOC_HAVE_DLSYM
#include <dlfcn.h>
#endif
static bool static bool
pthread_create_fptr_init(void) { pthread_create_fptr_init(void) {
if (pthread_create_fptr != NULL) { if (pthread_create_fptr != NULL) {
@ -830,7 +833,11 @@ pthread_create_fptr_init(void) {
* wrapper for pthread_create; and 2) application may define its own * wrapper for pthread_create; and 2) application may define its own
* wrapper as well (and can call malloc within the wrapper). * wrapper as well (and can call malloc within the wrapper).
*/ */
#ifdef JEMALLOC_HAVE_DLSYM
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create"); pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
#else
pthread_create_fptr = NULL;
#endif
if (pthread_create_fptr == NULL) { if (pthread_create_fptr == NULL) {
if (config_lazy_lock) { if (config_lazy_lock) {
malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, " malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "