From: Artem Boldariev Date: Mon, 16 Jan 2023 16:31:08 +0000 (+0200) Subject: Fix building BIND on DragonFly BSD (on both older an newer versions) X-Git-Tag: v9.19.10~26^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=942569a1bb104002215286dae5fed98d783519ad;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/isc/jemalloc_shim.h b/lib/isc/jemalloc_shim.h index c1b6f9c9aae..f01e256b092 100644 --- a/lib/isc/jemalloc_shim.h +++ b/lib/isc/jemalloc_shim.h @@ -41,7 +41,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 7abb743a587..fdb2a597d83 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -45,10 +45,13 @@ #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 +#define JEMALLOC_API_SUPPORTED 1 #elif defined(HAVE_JEMALLOC) #include +#define JEMALLOC_API_SUPPORTED 1 #if JEMALLOC_VERSION_MAJOR < 4 #define sdallocx(ptr, size, flags) dallocx(ptr, flags) @@ -437,12 +440,12 @@ mem_initialize(void) { /* * Check if the values copied from jemalloc still match */ -#if defined(HAVE_MALLOC_NP_H) || defined(HAVE_JEMALLOC) +#ifdef JEMALLOC_API_SUPPORTED RUNTIME_CHECK(ISC_MEM_ZERO == MALLOCX_ZERO); RUNTIME_CHECK(ISC_MEM_ALIGN(0) == MALLOCX_ALIGN(0)); RUNTIME_CHECK(ISC_MEM_ALIGN(sizeof(void *)) == MALLOCX_ALIGN(sizeof(void *))); -#endif /* defined(HAVE_MALLOC_NP_H) || defined(HAVE_JEMALLOC) */ +#endif /* JEMALLOC_API_SUPPORTED */ isc_mutex_init(&contextslock); ISC_LIST_INIT(contexts);