Index: llvm/cmake/config-ix.cmake =================================================================== --- llvm/cmake/config-ix.cmake +++ llvm/cmake/config-ix.cmake @@ -28,6 +28,8 @@ check_include_file(errno.h HAVE_ERRNO_H) check_include_file(fcntl.h HAVE_FCNTL_H) check_include_file(link.h HAVE_LINK_H) +check_include_file(malloc.h HAVE_MALLOC_H) +check_include_file(malloc_np.h HAVE_MALLOC_NP_H) check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H) if( NOT PURE_WINDOWS ) check_include_file(pthread.h HAVE_PTHREAD_H) @@ -200,7 +202,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) +elseif(HAVE_MALLOC_H) + # 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) Index: llvm/include/llvm/Config/config.h.cmake =================================================================== --- llvm/include/llvm/Config/config.h.cmake +++ llvm/include/llvm/Config/config.h.cmake @@ -127,6 +127,12 @@ /* Define to 1 if you have the `mallinfo' function. */ #cmakedefine HAVE_MALLINFO ${HAVE_MALLINFO} +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_H ${HAVE_MALLOC_MALLOC_H} + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MALLOC_NP_H ${HAVE_MALLOC_MALLOC_NP_H} + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_MALLOC_MALLOC_H ${HAVE_MALLOC_MALLOC_H} Index: llvm/lib/Support/Unix/Process.inc =================================================================== --- llvm/lib/Support/Unix/Process.inc +++ llvm/lib/Support/Unix/Process.inc @@ -32,10 +32,10 @@ #if HAVE_SIGNAL_H #include #endif -#if defined(HAVE_MALLINFO) +#ifdef HAVE_MALLOC_H #include #endif -#if defined(HAVE_MALLCTL) +#ifdef HAVE_MALLOC_NP_H #include #endif #ifdef HAVE_MALLOC_MALLOC_H