From: Erwin Janssen Date: Thu, 5 Jan 2017 18:10:31 +0000 (+0100) Subject: Add lib/vmalloc to CMake build X-Git-Tag: 2.42.0~213^2^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a31919f05dd877548210acbe9cb96b80d1e22d7;p=graphviz Add lib/vmalloc to CMake build The static library vmalloc has no dependencies. Various additional header, function and type checks have been added. --- diff --git a/cmake/config_checks.cmake b/cmake/config_checks.cmake index 8eb588258..8d658ea7e 100644 --- a/cmake/config_checks.cmake +++ b/cmake/config_checks.cmake @@ -1,15 +1,30 @@ # Header checks include(CheckIncludeFile) -check_include_file(unistd.h HAVE_UNISTD_H) +check_include_file( malloc.h HAVE_MALLOC_H ) +check_include_file( stat.h HAVE_STAT_H ) +check_include_file( sys/stat.h HAVE_SYS_STAT_H ) +check_include_file( unistd.h HAVE_UNISTD_H ) # Function checks include(CheckFunctionExists) check_function_exists( drand48 HAVE_DRAND48 ) check_function_exists( cbrt HAVE_CBRT ) +check_function_exists( getpagesize HAVE_GETPAGESIZE) +check_function_exists( mallinfo HAVE_MALLINFO ) +check_function_exists( mallopt HAVE_MALLOPT ) +check_function_exists( mstats HAVE_MSTATS ) check_function_exists( srand48 HAVE_SRAND48 ) check_function_exists( strcasecmp HAVE_STRCASECMP ) +# Type checks +# The function check_size_type also checks if the type exists +# and sets HAVE_${VARIABLE} accordingly. +include(CheckTypeSize) + +check_type_size( ssize_t SSIZE_T ) +check_type_size( intptr_t INTPTR_T ) + # Write check results to config.h header configure_file(config-cmake.h.in config.h) diff --git a/config-cmake.h.in b/config-cmake.h.in index 4480e4928..5a58d6539 100644 --- a/config-cmake.h.in +++ b/config-cmake.h.in @@ -2,10 +2,26 @@ #define PACKAGE_VERSION "@GRAPHVIZ_VERSION_FULL@" // Include headers +#cmakedefine HAVE_MALLOC_H +#cmakedefine HAVE_STAT_H +#cmakedefine HAVE_SYS_STAT_H #cmakedefine HAVE_UNISTD_H // Functions #cmakedefine HAVE_DRAND48 #cmakedefine HAVE_CBRT +#cmakedefine HAVE_GETPAGESIZE +#cmakedefine HAVE_MALLINFO +#cmakedefine HAVE_MALLOPT +#cmakedefine HAVE_MSTATS #cmakedefine HAVE_SRAND48 #cmakedefine HAVE_STRCASECMP + +// Types +#cmakedefine HAVE_SSIZE_T +#cmakedefine HAVE_INTPTR_T + +// Typedefs for missing types +#ifndef HAVE_SSIZE_T +typedef int ssize_t; +#endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 20a660c1a..7561c7f41 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(label) add_subdirectory(patchwork) add_subdirectory(pathplan) add_subdirectory(twopigen) +add_subdirectory(vmalloc) # Dependent on: cdt add_subdirectory(cgraph) diff --git a/lib/vmalloc/CMakeLists.txt b/lib/vmalloc/CMakeLists.txt new file mode 100644 index 000000000..d6b4e30a5 --- /dev/null +++ b/lib/vmalloc/CMakeLists.txt @@ -0,0 +1,28 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(vmalloc STATIC + # Header files + vmalloc.h + vmhdr.h + + # Source files + malloc.c + vmbest.c + vmclear.c + vmclose.c + vmdcheap.c + vmdebug.c + vmdisc.c + vmlast.c + vmopen.c + vmpool.c + vmprivate.c + vmprofile.c + vmregion.c + vmsegment.c + vmset.c + vmstat.c + vmstrdup.c + vmtrace.c + vmwalk.c +) diff --git a/lib/vmalloc/malloc.c b/lib/vmalloc/malloc.c index 864db41ce..ca9a36139 100644 --- a/lib/vmalloc/malloc.c +++ b/lib/vmalloc/malloc.c @@ -33,10 +33,10 @@ int _STUB_malloc; ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if HAVE_STAT_H +#ifdef HAVE_STAT_H #include #else -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H #include #endif #endif diff --git a/lib/vmalloc/vmhdr.h b/lib/vmalloc/vmhdr.h index 4c1f3c25e..441d9da59 100644 --- a/lib/vmalloc/vmhdr.h +++ b/lib/vmalloc/vmhdr.h @@ -24,8 +24,6 @@ extern "C" { #include #endif -#include - /* Common types, and macros for vmalloc functions. ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. @@ -33,6 +31,9 @@ extern "C" { #include "config.h" +#include +#include + #ifdef HAVE_SYS_TYPES_H # include #endif // HAVE_SYS_TYPES_H @@ -80,7 +81,7 @@ extern "C" { #define COUNT(n) ((n) += 1) #endif /*DEBUG*/ #define VMPAGESIZE 8192 -#if HAVE_GETPAGESIZE +#ifdef HAVE_GETPAGESIZE #define GETPAGESIZE(x) ((x) ? (x) : \ (((x)=getpagesize()) < VMPAGESIZE ? ((x)=VMPAGESIZE) : (x)) ) #else