freebsd-nq/lib/libthr/thread/Makefile.inc
Konstantin Belousov 381c2d2e9a Untangle jemalloc and mutexes initialization.
The need to use libc malloc(3) from some places in libthr always
caused issues.  For instance, per-thread key allocation was switched to
use plain mmap(2) to get storage, because some third party mallocs
used keys for implementation of calloc(3).

Even more important, libthr calls calloc(3) during initialization of
pthread mutexes, and jemalloc uses pthread mutexes.  Jemalloc provides
some way to both postpone the initialization, and to make
initialization to use specialized allocator, but this is very fragile
and often breaks.  See the referenced PR for another example.

Add the small malloc implementation used by rtld, to libthr. Use it in
thr_spec.c and for mutexes initialization. This avoids the issues with
mutual dependencies between malloc and libthr in principle.  The
drawback is that some more allocations are not interceptable for
alternate malloc implementations.  There should be not too much memory
use from this allocator, and the alternative, direct use of mmap(2) is
obviously worse.

PR:	235211
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D18988
2019-01-29 22:46:44 +00:00

62 lines
976 B
Makefile

# $FreeBSD$
# thr sources
.PATH: ${.CURDIR}/thread
SRCS+= \
thr_affinity.c \
thr_attr.c \
thr_barrier.c \
thr_barrierattr.c \
thr_cancel.c \
thr_clean.c \
thr_concurrency.c \
thr_cond.c \
thr_condattr.c \
thr_create.c \
thr_ctrdtr.c \
thr_detach.c \
thr_equal.c \
thr_event.c \
thr_exit.c \
thr_fork.c \
thr_getprio.c \
thr_getcpuclockid.c \
thr_getschedparam.c \
thr_getthreadid_np.c \
thr_info.c \
thr_init.c \
thr_join.c \
thr_list.c \
thr_kern.c \
thr_kill.c \
thr_main_np.c \
thr_malloc.c \
thr_multi_np.c \
thr_mutex.c \
thr_mutexattr.c \
thr_once.c \
thr_printf.c \
thr_pshared.c \
thr_pspinlock.c \
thr_resume_np.c \
thr_rtld.c \
thr_rwlock.c \
thr_rwlockattr.c \
thr_self.c \
thr_sem.c \
thr_setprio.c \
thr_setschedparam.c \
thr_sig.c \
thr_single_np.c \
thr_sleepq.c \
thr_spec.c \
thr_spinlock.c \
thr_stack.c \
thr_syscalls.c \
thr_suspend_np.c \
thr_switch_np.c \
thr_symbols.c \
thr_umtx.c \
thr_yield.c