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

Roberto Bagnara bagnara at cs.unipr.it
Tue Jun 18 19:30:06 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.

Why is not Yap calling PreAllocBigNum first?
I mean, initializing things so that AllocBigNumSpace and friends
work correctly would seem something to be done in the first lines
of Yap's main function.
Wouldn't this solve all the problems?  The PPL does not really care
where GMP takes the memory from: if it comes from Yap's stacks that
is fine.  In other words, PPL just uses the GMP's entry point without
making any further assumption.
All the best

     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