From ce332f8c5e81db5cf4edd740e62059eed20dec9a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 25 Jun 2020 17:28:02 -0700 Subject: [PATCH] freebsd: malloc_usable_size check malloc_np.h (#7009) Summary: Per https://www.unix.com/man-page/freebsd/3/malloc_usable_size/ malloc_usable_size is in malloc_np.h as its a non-standard API. Without patch it just fails to detect from ./CMakeFiles/CMakeError.log In file included from /home/dan/build-rocksdb/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:2: /usr/include/malloc.h:3:2: error: " has been replaced by " ^ /home/dan/build-rocksdb/CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8:19: error: use of undeclared identifier 'malloc_usable_size' return ((int*)(&malloc_usable_size))[argc]; ^ 2 errors generated. Pull Request resolved: https://github.com/facebook/rocksdb/pull/7009 Reviewed By: riversand963 Differential Revision: D22176093 Pulled By: ajkr fbshipit-source-id: da980f3d343b6d9b0c70d7827c6df495f3fb1ade --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28f7eb894..91647d83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -511,7 +511,11 @@ if(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP) endif() include(CheckCXXSymbolExists) -check_cxx_symbol_exists(malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE) +if(CMAKE_SYSTEM_NAME MATCHES "^FreeBSD") + check_cxx_symbol_exists(malloc_usable_size malloc_np.h HAVE_MALLOC_USABLE_SIZE) +else() + check_cxx_symbol_exists(malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE) +endif() if(HAVE_MALLOC_USABLE_SIZE) add_definitions(-DROCKSDB_MALLOC_USABLE_SIZE) endif()