]> granicus.if.org Git - graphviz/commitdiff
Add lib/vmalloc to CMake build
authorErwin Janssen <erwinjanssen@outlook.com>
Thu, 5 Jan 2017 18:10:31 +0000 (19:10 +0100)
committerErwin Janssen <erwinjanssen@outlook.com>
Thu, 19 Jan 2017 11:53:51 +0000 (12:53 +0100)
The static library vmalloc has no dependencies. Various additional
header, function and type checks have been added.

cmake/config_checks.cmake
config-cmake.h.in
lib/CMakeLists.txt
lib/vmalloc/CMakeLists.txt [new file with mode: 0644]
lib/vmalloc/malloc.c
lib/vmalloc/vmhdr.h

index 8eb588258c158333343fde7908c10480b4eff21a..8d658ea7e7c5f5eed3230da10cd008611db29d1b 100644 (file)
@@ -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)
index 4480e4928f02485d26aa50e6481ca53ea9c754a2..5a58d653924785ed213c9cc5bac55c552406ea0b 100644 (file)
@@ -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
index 20a660c1a2e437ff92222335b80cc82f992dd60e..7561c7f4138e55c20766565354d6f1edea902ad9 100644 (file)
@@ -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 (file)
index 0000000..d6b4e30
--- /dev/null
@@ -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
+)
index 864db41cec9afba3081536ab1aa1aea0095baab8..ca9a36139f9cb763c01512a90b6b4902ef0d8e9f 100644 (file)
@@ -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       <stat.h>
 #else
-#if HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
 #include       <sys/stat.h>
 #endif
 #endif
index 4c1f3c25e8710358b2debbf923549b08f3f95eb4..441d9da5921d84ca79353b3ddf9c2c8a8fb25b0a 100644 (file)
@@ -24,8 +24,6 @@ extern "C" {
 #include <io.h>
 #endif
 
-#include <inttypes.h>
-
 /*     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 <inttypes.h>
+#include <stdlib.h>
+
 #ifdef HAVE_SYS_TYPES_H
 #   include <sys/types.h>
 #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