Skip to content

Commit 13685ab

Browse files
committed
Normalize background thread configuration.
Also fix a compilation error #ifndef JEMALLOC_PTHREAD_CREATE_WRAPPER.
1 parent 94d655b commit 13685ab

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ if test "x$abi" != "xpecoff" ; then
14521452
[AC_SEARCH_LIBS([pthread_create], , ,
14531453
AC_MSG_ERROR([libpthread is missing]))])
14541454
wrap_syms="${wrap_syms} pthread_create"
1455+
have_pthread="1"
14551456
dnl Check if we have dlsym support.
14561457
have_dlsym="1"
14571458
AC_CHECK_HEADERS([dlfcn.h],
@@ -1933,6 +1934,15 @@ if test "x${enable_zone_allocator}" = "x1" ; then
19331934
AC_DEFINE([JEMALLOC_ZONE], [ ])
19341935
fi
19351936

1937+
dnl ============================================================================
1938+
dnl Enable background threads if possible.
1939+
1940+
if test "x${have_pthread}" = "x1" -a "x${have_dlsym}" = "x1" \
1941+
-a "x${je_cv_os_unfair_lock}" != "xyes" \
1942+
-a "x${je_cv_osspin}" != "xyes" ; then
1943+
AC_DEFINE([JEMALLOC_BACKGROUND_THREAD])
1944+
fi
1945+
19361946
dnl ============================================================================
19371947
dnl Check for glibc malloc hooks
19381948

include/jemalloc/internal/jemalloc_internal_defs.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@
316316
/* GNU specific sched_setaffinity support */
317317
#undef JEMALLOC_HAVE_SCHED_SETAFFINITY
318318

319+
/*
320+
* If defined, all the features necessary for background threads are present.
321+
*/
322+
#undef JEMALLOC_BACKGROUND_THREAD
323+
319324
/*
320325
* If defined, jemalloc symbols are not exported (doesn't work when
321326
* JEMALLOC_PREFIX is not defined).

include/jemalloc/internal/jemalloc_preamble.h.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ static const bool force_ivsalloc =
168168
false
169169
#endif
170170
;
171-
172-
#if (defined(JEMALLOC_HAVE_PTHREAD) && defined(JEMALLOC_HAVE_DLSYM) \
173-
&& !defined(JEMALLOC_OSSPIN) && !defined(JEMALLOC_OS_UNFAIR_LOCK))
174-
/* Currently background thread supports pthread only. */
175-
#define JEMALLOC_BACKGROUND_THREAD
176-
#endif
177171
static const bool have_background_thread =
178172
#ifdef JEMALLOC_BACKGROUND_THREAD
179173
true

src/background_thread.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,9 @@ background_thread_stats_read(tsdn_t *tsdn, background_thread_stats_t *stats) {
635635
void
636636
background_thread_ctl_init(tsdn_t *tsdn) {
637637
malloc_mutex_assert_not_owner(tsdn, &background_thread_lock);
638+
#ifdef JEMALLOC_PTHREAD_CREATE_WRAPPER
638639
pthread_once(&once_control, pthread_create_wrapper_once);
640+
#endif
639641
}
640642

641643
#endif /* defined(JEMALLOC_BACKGROUND_THREAD) */

0 commit comments

Comments
 (0)