[PATCH] D59249: [llvm] [Support] mallctl() is in malloc.h on NetBSD

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 12 06:24:34 PDT 2019


mgorny created this revision.
mgorny added reviewers: krytarowski, joerg, davide, beanz.
Herald added subscribers: kristina, hiraditya.
Herald added a project: LLVM.

Fix the CMake check and Support code for mallctl() to account for
the function being added to malloc.h recently.  In both cases,
the inconsistency between platforms is resolved by checking for
malloc_np.h first and falling back to malloc.h if it is not present.


Repository:
  rL LLVM

https://reviews.llvm.org/D59249

Files:
  llvm/cmake/config-ix.cmake
  llvm/lib/Support/Unix/Process.inc


Index: llvm/lib/Support/Unix/Process.inc
===================================================================
--- llvm/lib/Support/Unix/Process.inc
+++ llvm/lib/Support/Unix/Process.inc
@@ -36,7 +36,11 @@
 #include <malloc.h>
 #endif
 #if defined(HAVE_MALLCTL)
-#include <malloc_np.h>
+#  if defined(HAVE_MALLOC_NP_H)
+#    include <malloc_np.h>
+#  else
+#    include <malloc.h>
+#  endif
 #endif
 #ifdef HAVE_MALLOC_MALLOC_H
 #include <malloc/malloc.h>
Index: llvm/cmake/config-ix.cmake
===================================================================
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -29,6 +29,7 @@
 check_include_file(fcntl.h HAVE_FCNTL_H)
 check_include_file(link.h HAVE_LINK_H)
 check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
+check_include_file(malloc_np.h HAVE_MALLOC_NP_H)
 if( NOT PURE_WINDOWS )
   check_include_file(pthread.h HAVE_PTHREAD_H)
 endif()
@@ -200,7 +201,12 @@
 set(CMAKE_REQUIRED_DEFINITIONS "-D_LARGEFILE64_SOURCE")
 check_symbol_exists(lseek64 "sys/types.h;unistd.h" HAVE_LSEEK64)
 set(CMAKE_REQUIRED_DEFINITIONS "")
-check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
+if(HAVE_MALLOC_NP_H)
+  check_symbol_exists(mallctl malloc_np.h HAVE_MALLCTL)
+else()
+  # NetBSD has mallctl() in malloc.h
+  check_symbol_exists(mallctl malloc.h HAVE_MALLCTL)
+endif()
 check_symbol_exists(mallinfo malloc.h HAVE_MALLINFO)
 check_symbol_exists(malloc_zone_statistics malloc/malloc.h
                     HAVE_MALLOC_ZONE_STATISTICS)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59249.190244.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190312/b44cc004/attachment.bin>


More information about the llvm-commits mailing list