Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ include(CheckFTS)
include(CheckUnamePosix)
# Check support for file descriptor passing
include(CheckFDPassing)
# Check support for mallinfo memory stats
include(CheckMallinfo)

# Check if big-endian
include(TestBigEndian)
Expand Down
8 changes: 8 additions & 0 deletions cmake/CheckMallinfo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <malloc.h>

int main()
{
struct mallinfo mi;
mi = mallinfo();
return 0;
}
26 changes: 26 additions & 0 deletions cmake/CheckMallinfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Check for mallinfo(3) sys call.
#

GET_FILENAME_COMPONENT(_selfdir_CheckMallinfo
"${CMAKE_CURRENT_LIST_FILE}" PATH)

# Check that the POSIX compliant uname(2) call works properly (HAVE_UNAME_SYSCALL)
try_run(
# Name of variable to store the run result (process exit status; number) in:
test_run_result
# Name of variable to store the compile result (TRUE or FALSE) in:
test_compile_result
# Binary directory:
${CMAKE_CURRENT_BINARY_DIR}
# Source file to be compiled:
${_selfdir_CheckMallinfo}/CheckMallinfo.c
# Where to store the output produced during compilation:
COMPILE_OUTPUT_VARIABLE test_compile_output
# Where to store the output produced by running the compiled executable:
RUN_OUTPUT_VARIABLE test_run_output )

# Did compilation succeed and process return 0 (success)?
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
set(HAVE_MALLINFO 1)
endif()
Loading