From fb17acca9c26d3299c3eece032584345b28d0af0 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 2 Dec 2008 22:41:04 +0100 Subject: [PATCH] Add backup mp_get_memory_functions implementation for use with old gmps --- Makefile.am | 5 +++++ configure.in | 6 ++++++ include/cloog/int.h.in | 6 ++++++ source/mp_get_memory_functions.c | 14 ++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 source/mp_get_memory_functions.c diff --git a/Makefile.am b/Makefile.am index 2df7480..6e91cd5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,12 @@ bin_PROGRAMS = cloog lib_LTLIBRARIES = @CLOOG_LIBRARIES@ EXTRA_LTLIBRARIES = libcloog-polylib.la libcloog-isl.la +if NEED_GET_MEMORY_FUNCTIONS +GET_MEMORY_FUNCTIONS=source/mp_get_memory_functions.c +endif + SOURCES_CORE = \ + $(GET_MEMORY_FUNCTIONS) \ source/block.c \ source/clast.c \ source/int.c \ diff --git a/configure.in b/configure.in index 2066327..31f63f0 100644 --- a/configure.in +++ b/configure.in @@ -120,6 +120,12 @@ system) __gmpz_init, [LIBS="$LIBS -lgmp"], [AC_MSG_ERROR(Can't find gmp library.)]) + need_get_memory_functions=false + AC_CHECK_DECLS(mp_get_memory_functions,[],[ + need_get_memory_functions=true + ],[#include ]) + AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, + test x$need_get_memory_functions = xtrue) ;; esac diff --git a/include/cloog/int.h.in b/include/cloog/int.h.in index 1879753..21b3091 100644 --- a/include/cloog/int.h.in +++ b/include/cloog/int.h.in @@ -11,6 +11,12 @@ #if defined(CLOOG_INT_GMP) #include #include +#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 #endif #if defined(__cplusplus) diff --git a/source/mp_get_memory_functions.c b/source/mp_get_memory_functions.c new file mode 100644 index 0000000..e14e336 --- /dev/null +++ b/source/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; +} -- 2.11.4.GIT