From: Sven Verdoolaege Date: Tue, 2 Dec 2008 20:22:01 +0000 (+0100) Subject: Add backup mp_get_memory_functions implementation for use with old gmps X-Git-Tag: isl-0.01~350 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21f70a2e26e7ea5466f56abd0087eea6eeda91fa;p=platform%2Fupstream%2Fisl.git Add backup mp_get_memory_functions implementation for use with old gmps --- diff --git a/Makefile.am b/Makefile.am index 7f78b80..78ab76a 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 8c9e208..e084a75 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 ]) +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 3445e55..1326664 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 0000000..e14e336 --- /dev/null +++ b/mp_get_memory_functions.c @@ -0,0 +1,14 @@ +#include + +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; +}