summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2008-12-02 21:22:01 +0100
committerSven Verdoolaege <skimo@kotnet.org>2008-12-02 21:34:33 +0100
commit21f70a2e26e7ea5466f56abd0087eea6eeda91fa (patch)
tree40dc58aacf2a3392cb6e173cb11809afb82b0ae4
parentf6038f29c474ee9916c67ad8d040aeaaa8ab09af (diff)
downloadisl-21f70a2e26e7ea5466f56abd0087eea6eeda91fa.tar.gz
isl-21f70a2e26e7ea5466f56abd0087eea6eeda91fa.tar.bz2
isl-21f70a2e26e7ea5466f56abd0087eea6eeda91fa.zip
Add backup mp_get_memory_functions implementation for use with old gmps
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac8
-rw-r--r--include/isl_int.h7
-rw-r--r--mp_get_memory_functions.c14
4 files changed, 34 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 7f78b808..78ab76a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,9 +33,14 @@ if BUNDLED_PIPLIB
PIPLIB_LA = $(top_builddir)/piplib/libpiplibMP.la
endif
+if NEED_GET_MEMORY_FUNCTIONS
+GET_MEMORY_FUNCTIONS=mp_get_memory_functions.c
+endif
+
libisl_la_SOURCES = \
$(ISL_PIPLIB) \
$(ISL_POLYLIB) \
+ $(GET_MEMORY_FUNCTIONS) \
isl_affine_hull.c \
isl_blk.c \
isl_constraint.c \
diff --git a/configure.ac b/configure.ac
index 8c9e2089..e084a75b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,14 @@ if test "x$with_gmp_prefix" != "x"; then
GMP_CPPFLAGS="-I$with_gmp_prefix/include"
GMP_LDFLAGS="-L$with_gmp_prefix/lib"
fi
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
+need_get_memory_functions=false
+AC_CHECK_DECLS(mp_get_memory_functions,[],[
+ need_get_memory_functions=true
+],[#include <gmp.h>])
+CPPFLAGS="$SAVE_CPPFLAGS"
+AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
AC_DEFUN([ISL_SUBMODULE],[
AC_ARG_WITH($1_prefix,
diff --git a/include/isl_int.h b/include/isl_int.h
index 3445e553..13266641 100644
--- a/include/isl_int.h
+++ b/include/isl_int.h
@@ -9,6 +9,13 @@
extern "C" {
#endif
+#ifndef mp_get_memory_functions
+void mp_get_memory_functions(
+ void *(**alloc_func_ptr) (size_t),
+ void *(**realloc_func_ptr) (void *, size_t, size_t),
+ void (**free_func_ptr) (void *, size_t));
+#endif
+
/* isl_int is the basic integer type. It currently always corresponds
* to a gmp mpz_t, but in the future, different types such as long long
* or cln::cl_I will be supported.
diff --git a/mp_get_memory_functions.c b/mp_get_memory_functions.c
new file mode 100644
index 00000000..e14e336c
--- /dev/null
+++ b/mp_get_memory_functions.c
@@ -0,0 +1,14 @@
+#include <gmp.h>
+
+void mp_get_memory_functions(
+ void *(**alloc_func_ptr) (size_t),
+ void *(**realloc_func_ptr) (void *, size_t, size_t),
+ void (**free_func_ptr) (void *, size_t))
+{
+ if (alloc_func_ptr)
+ *alloc_func_ptr = __gmp_allocate_func;
+ if (realloc_func_ptr)
+ *realloc_func_ptr = __gmp_reallocate_func;
+ if (free_func_ptr)
+ *free_func_ptr = __gmp_free_func;
+}