From cb9f8c08d5f536af5138146acf5f0e864d3746aa Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Mon, 16 Jan 2023 18:31:08 +0200 Subject: [PATCH] Fix building BIND on DragonFly BSD (on both older an newer versions) This commit ensures that BIND and supplementary tools still can be built on newer versions of DragonFly BSD. It used to be the case, but somewhere between versions 6.2 and 6.4 the OS developers rearranged headers and moved some function definitions around. Before that the fact that it worked was more like a coincidence, this time we, at least, looked at the related man pages included with the OS. No in depth testing has been done on this OS as we do not really support this platform - so it is more like a goodwill act. We can, however, use this platform for testing purposes, too. Also, we know that the OS users do use BIND, as it is included in its ports directory. Building with './configure' and './configure --without-jemalloc' have been fixed and are known to work at the time the commit is made. (cherry picked from commit 942569a1bb104002215286dae5fed98d783519ad) --- lib/isc/jemalloc_shim.h | 8 ++++++++ lib/isc/mem.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/isc/jemalloc_shim.h b/lib/isc/jemalloc_shim.h index 8d99c7b776..37e984ae1a 100644 --- a/lib/isc/jemalloc_shim.h +++ b/lib/isc/jemalloc_shim.h @@ -64,7 +64,15 @@ sallocx(void *ptr, int flags) { #elif HAVE_MALLOC_USABLE_SIZE +#ifdef __DragonFly__ +/* + * On DragonFly BSD 'man 3 malloc' advises us to include the following + * header to have access to malloc_usable_size(). + */ +#include +#else #include +#endif static inline size_t sallocx(void *ptr, int flags) { diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 61b7222491..df75f6eab6 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -44,7 +44,8 @@ #include #endif /* HAVE_JSON_C */ -#if defined(HAVE_MALLOC_NP_H) +/* On DragonFly BSD the header does not provide jemalloc API */ +#if defined(HAVE_MALLOC_NP_H) && !defined(__DragonFly__) #include #elif defined(HAVE_JEMALLOC) #include