]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix building BIND on DragonFly BSD (on both older an newer versions)
authorArtem Boldariev <artem@boldariev.com>
Mon, 16 Jan 2023 16:31:08 +0000 (18:31 +0200)
committerArtem Boldariev <artem@boldariev.com>
Thu, 19 Jan 2023 22:19:12 +0000 (00:19 +0200)
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.

lib/isc/jemalloc_shim.h
lib/isc/mem.c

index c1b6f9c9aae888a1ffef56b2270d58d6148c589e..f01e256b092e0793445d6c37178e2540da6c133c 100644 (file)
@@ -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 <malloc_np.h>
+#else
 #include <malloc.h>
+#endif
 
 static inline size_t
 sallocx(void *ptr, int flags) {
index 7abb743a587201162d6a8c375d3edb42cce535f2..fdb2a597d834db4ad8a65860c5118a0b9b0d0e17 100644 (file)
 #include <json_object.h>
 #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 <malloc_np.h>
+#define JEMALLOC_API_SUPPORTED 1
 #elif defined(HAVE_JEMALLOC)
 #include <jemalloc/jemalloc.h>
+#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);