diff --git a/lib/isc/jemalloc_shim.h b/lib/isc/jemalloc_shim.h index c1b6f9c9aa..f01e256b09 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 7abb743a58..fdb2a597d8 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);