use of ALLOC(), SIZE(), PTR() macros in libgmp

Jan Nijtmans nijtmans at
Tue Dec 11 15:46:14 CET 2007

Hello, GMP developers,

I'm experimenting with using GMP in a new GPL project, and thereby I
want to experiment with a more efficient memory occupation by
modifying the ALLOC, SIZE and PTR macro's. Those changes
are not intended to be taken over by libgmp (unless this change
turns out to be highly beneficial), but I noticed that those
macros are almost not used in GMP. Most code just uses the _mp_alloc,
_mp_size and _mp_d fields directly.

My first question is, how can I help to make all GMP code use those
macro's (and EXP, PREC as well). I already made a local version of
GMP with all those replacements done, but I wouldn't be surprised
if others are interested in this as well. Of course, I can make a fork,
but this change is risk-less and I have no objection at all (in the contrary!)
to share my experiences with you.

Second, I noted that the LIMBS() macro is only used in mpz/combit.c,
and nowhere else. Here is a small diff, changing this to the PTR()
macro, so the LIMBS() macro can be eliminated. Let this be my
first (tiny) contribution to libgmp.

         Jan Nijtmans
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diff.txt

More information about the gmp-devel mailing list