ENH: Updated metis download URL to 5.0.1
[freefoam.git] / ThirdParty / metis.patch
blob98be2d012d0fd96764f4cdc48f4ea37a9b198323
1 From 7d8907397a37b403888ba9e57dd22d3b4ac7c7a5 Mon Sep 17 00:00:00 2001
2 From: Michael Wild <themiwi@users.sourceforge.net>
3 Date: Thu, 16 Jun 2011 17:16:54 +0200
4 Subject: [PATCH] Properly detect malloc.h and mallinfo
6 and make GKLIB_PATH absolute.
8 Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
9 ---
10 GKlib/GKlibSystem.cmake | 86 ++++++++++++++++++++++++++++++++++++++++++++++++
11 GKlib/gk_config.h.in | 34 ++++++++++++++++++
12 GKlib/gk_dlmalloc.h | 11 +++---
13 3 files changed, 126 insertions(+), 5 deletions(-)
14 create mode 100644 GKlib/gk_config.h.in
16 diff --git a/GKlib/GKlibSystem.cmake b/GKlib/GKlibSystem.cmake
17 index a7af9cb..e2de364 100644
18 --- a/GKlib/GKlibSystem.cmake
19 +++ b/GKlib/GKlibSystem.cmake
20 @@ -7,6 +7,10 @@ option(ASSERT2 "additional assertions" OFF)
21 option(DEBUG "add debugging support" OFF)
22 option(OPENMP "enable OpenMP support" OFF)
24 +if(NOT IS_ABSOLUTE "${GKLIB_PATH}")
25 + set(GKLIB_PATH "${PROJECT_SOURCE_DIR}/${GKLIB_PATH}")
26 +endif()
28 if(WIN32)
29 set(GKlib_COPTS "/Ox")
30 set(GKlib_COPTIONS "-DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE -DUSE_GKREGEX")
31 @@ -77,3 +81,85 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GKlib_COPTIONS} ${GKlib_COPTS}")
33 file(GLOB GKlib_sources ${GKLIB_PATH}/*.c)
34 file(GLOB GKlib_includes ${GKLIB_PATH}/*.h)
36 +# do we have mallinfo() and struct mallinfo? this is a bit tedious...
37 +check_function_exists(mallinfo HAVE_MALLINFO)
38 +mark_as_advanced(HAVE_MALLINFO)
39 +if(HAVE_MALLINFO AND NOT DEFINED MALLINFO_FIELD_TYPE)
40 + # output is:
41 + # sizeof(int);sizeof(size_t);sizeof(mallinfo.arena);signedness of mallinfo.arena
42 + set(MALLINFO_SRC
43 +#include <malloc.h>
44 +#include <stdio.h>
45 +int main(int argc, char* argv[]){
46 + struct mallinfo mi = mallinfo();
47 + mi.arena = -1;
48 + char sig = mi.arena<0;
49 + printf(\"%lu;%lu;%lu;%d\\n\",sizeof(int),sizeof(size_t),sizeof(mi.arena),sig);
50 + return 0;
51 +}"
52 + )
53 + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
54 + "${MALLINFO_SRC}\n"
55 + )
56 + try_run(MALLINFO_RUNS MALLINFO_COMPILES
57 + ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
58 + RUN_OUTPUT_VARIABLE MALLINFO_OUTPUT
59 + )
60 + set(MALLINFO_USABLE FALSE)
61 + if(MALLINFO_COMPILES AND NOT MALLINFO_RUNS STREQUAL FAILED_TO_RUN)
62 + set(MALLINFO_OUTPUT ${MALLINFO_OUTPUT})
63 + list(GET MALLINFO_OUTPUT 0 SIZEOF_INT)
64 + list(GET MALLINFO_OUTPUT 1 SIZEOF_SIZE_T)
65 + list(GET MALLINFO_OUTPUT 2 SIZEOF_MALLINFO_ARENA)
66 + list(GET MALLINFO_OUTPUT 3 MALLINFO_ARENA_SIGNED)
67 + if(CMAKE_SIZEOF_VOID_P EQUAL 4)
68 + # 32 bit, only look out for signedness
69 + if(MALLINFO_ARENA_SIGNED)
70 + set(DEFAULT_MALLINFO_FIELD_TYPE int)
71 + else()
72 + set(DEFAULT_MALLINFO_FIELD_TYPE size_t)
73 + endif()
74 + # success
75 + set(MALLINFO_USABLE TRUE)
76 + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
77 + # 64 bit, more complicated...
78 + if(SIZEOF_MALLINFO_ARENA EQUAL ${SIZEOF_INT})
79 + # it is of int size
80 + if(MALLINFO_ARENA_SIGNED)
81 + set(DEFAULT_MALLINFO_FIELD_TYPE int)
82 + else()
83 + set(DEFAULT_MALLINFO_FIELD_TYPE unsigned)
84 + endif()
85 + # success
86 + set(MALLINFO_USABLE TRUE)
87 + elseif(SIZEOF_MALLINFO_ARENA EQUAL ${SIZEOF_SIZE_T})
88 + # it is of long int size (i.e. size_t)
89 + if(MALLINFO_ARENA_SIGNED)
90 + set(DEFAULT_MALLINFO_FIELD_TYPE "long int")
91 + else()
92 + set(DEFAULT_MALLINFO_FIELD_TYPE size_t)
93 + endif()
94 + # success
95 + set(MALLINFO_USABLE TRUE)
96 + endif()
97 + endif()
98 + endif()
99 + # was above code succesful?
100 + if(NOT MALLINFO_USABLE)
101 + set(HAVE_MALLINFO FALSE CACHE BOOL "Failed to run simple code using mallinfo." FORCE)
102 + message(STATUS "mallinfo not usable")
103 + endif()
104 +endif()
105 +if(NOT DEFINED DEFAULT_MALLINFO_FIELD_TYPE)
106 + # default
107 + set(DEFAULT_MALLINFO_FIELD_TYPE size_t)
108 +endif()
109 +# let the user override
110 +set(MALLINFO_FIELD_TYPE "${DEFAULT_MALLINFO_FIELD_TYPE}"
111 + CACHE STRING "Type of the fields in the mallinfo struct")
112 +mark_as_advanced(MALLINFO_FIELD_TYPE)
114 +configure_file("${GKLIB_PATH}/gk_config.h.in" "${PROJECT_BINARY_DIR}/gk_config.h")
116 +include_directories("${PROJECT_BINARY_DIR}")
117 diff --git a/GKlib/gk_config.h.in b/GKlib/gk_config.h.in
118 new file mode 100644
119 index 0000000..00cd2de
120 --- /dev/null
121 +++ b/GKlib/gk_config.h.in
122 @@ -0,0 +1,34 @@
123 +/* AUTOMATICALLY GENERATED. DO NOT EDIT! */
125 +#ifndef _GK_CONFIG_H
126 +#define _GK_CONFIG_H
128 +/* MALLINFO_FIELD_TYPE default: size_t
129 + * The type of the fields in the mallinfo struct. This was originally
130 + * defined as "int" in SVID etc, but is more usefully defined as
131 + * size_t. The value is used only if HAVE_MALLINFO is not set
132 + */
133 +#define MALLINFO_FIELD_TYPE @MALLINFO_FIELD_TYPE@
135 +/* This version of malloc supports the standard SVID/XPG mallinfo
136 + routine that returns a struct containing usage properties and
137 + statistics. It should work on any system that has a
138 + /usr/include/malloc.h defining struct mallinfo. The main
139 + declaration needed is the mallinfo struct that is returned (by-copy)
140 + by mallinfo(). The malloinfo struct contains a bunch of fields that
141 + are not even meaningful in this version of malloc. These fields are
142 + are instead filled by mallinfo() with other numbers that might be of
143 + interest.
145 + HAVE_MALLINFO should be set if you have a /usr/include/malloc.h file that
146 + includes a declaration of struct mallinfo. If so, it is included; else a
147 + compliant version is declared below. These must be precisely the same for
148 + mallinfo() to work. The original SVID version of this struct, defined on
149 + most systems with mallinfo, declares all fields as ints. But some others
150 + define as unsigned long. If your system defines the fields using a type of
151 + different width than listed here, you MUST #include your system version and
152 + #define HAVE_MALLINFO.
154 +#cmakedefine HAVE_MALLINFO
156 +#endif // _GK_CONFIG_H
157 diff --git a/GKlib/gk_dlmalloc.h b/GKlib/gk_dlmalloc.h
158 index a72b924..8006e1c 100644
159 --- a/GKlib/gk_dlmalloc.h
160 +++ b/GKlib/gk_dlmalloc.h
161 @@ -24,6 +24,8 @@
162 \version\verbatim $Id: gk_dlmalloc.h 1711 2007-05-18 17:05:27Z karypis $\endverbatim
165 +#include "gk_config.h"
167 #ifdef USE_DLMALLOC
169 /**********************************************************************
170 @@ -692,9 +694,9 @@ MAX_RELEASE_CHECK_RATE default: 255 unless not HAVE_MMAP
172 /* #define HAVE_USR_INCLUDE_MALLOC_H */
174 -#ifdef HAVE_USR_INCLUDE_MALLOC_H
175 -#include "/usr/include/malloc.h"
176 -#else /* HAVE_USR_INCLUDE_MALLOC_H */
177 +#ifdef HAVE_MALLINFO
178 +#include <malloc.h>
179 +#else /* HAVE_MALLINFO */
181 struct mallinfo {
182 MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
183 @@ -709,8 +711,7 @@ struct mallinfo {
184 MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
187 -#endif /* HAVE_USR_INCLUDE_MALLOC_H */
188 +#endif /* HAVE_MALLINFO */
189 #endif /* NO_MALLINFO */
193 1.7.4.1