[PPL-devel] Re: First part of the problem: GMP

Roberto Bagnara bagnara at cs.unipr.it
Tue Jun 18 20:12:02 CEST 2002


Vitor Santos Costa wrote:
> The problem seems to be that Yap defines its own allocation functions
> for gmp objects:
> 
> #ifdef USE_GMP
>   /* YAP style memory allocation */
>   mp_set_memory_functions(
> 			  AllocBigNumSpace,
> 			  ReAllocBigNumSpace,
> 			  FreeBigNumSpace);
> #endif
> 
> This allows Yap to work with such objects in its own
> stacks. Unfortunately, these functions require for another function,
> PreAllocBigNum to have been called before. In general, using them is a
> bit dangerous, because they assume they have control over the global stack.
> 
> I suppose Yap is polluting the application space, so the correct
> solution would be for Yap to reset these functions before entering
> user code. But this would make the interface slower for any
> application that doesn't use GMP.
> 
> A compromise might be for me to provide two interface functions
> (YapResetGMPFunctions() and YapSet GMPFunctions()) and for you to call
> them before you started manipulating GMP objects.

Hi Vitor,

I believe that calling mp_set_memory_functions repeatedly would mean that
we must abandon all the guarantees provided by GMP's interface.
In fact, the following paragraph is taken from GMP's manual:

   @strong{Be sure to call @code{mp_set_memory_functions} only when there are no
   active GMP objects allocated using the previous memory functions!  Usually
   that means calling it before any other GMP function.}

Ciao

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it




More information about the PPL-devel mailing list