Vincent Lefevre vincent at
Wed Jan 15 22:54:27 UTC 2014

On 2014-01-15 23:23:28 +0100, Niels Möller wrote:
> Zimmermann Paul <Paul.Zimmermann at> writes:
> > 1) I had to add #define mpz_init __gmpz_init, because in MPFR
> >    configure we check for __gmpz_init
> I don't think that's the right way. mini-gmp should not pretend to be the
> real thing.
> I recommend having a configure check which tests for the *real* gmp, and
> if gmp is not available (or some --enable-mini-gmp option is used), have
> fallback code in configure which explicitly sets up use of mini-gmp.

I think that one should have --enable-mini-gmp. I don't like the
fallback, because a failing gmp in configure test could mean some
error from the user such as incorrect ABI or the user forgot to
install libgmp-dev.

> > Changes in mini-gmp.h: I had to add the following:
> >
> >> #define __GNU_MP_VERSION            5
> >> #define __GNU_MP_VERSION_MINOR      1

That would be incorrect. MPFR uses that for compatibility issues.
But mini-gmp may not provide the same features.

> >> #define __gmp_const const

__gmp_const should be dropped from MPFR. mpfr.h has:

/* GMP's internal __gmp_const macro has been removed on 2012-03-04:
   const is standard and now assumed to be available. If the __gmp_const
   definition is no longer present in GMP, this probably means that GMP
   assumes that const is available; thus let's define it to const.
   Note: this is a temporary fix that can be backported to previous MPFR
   versions. In the future, __gmp_const should be replaced by const like
   in GMP. See MPFR bug 13947. */
#ifndef __gmp_const
# define __gmp_const const

With that, I don't even understand why the change in mini-gmp is

> >> #define __GMP_DECLSPEC

I think this should be a change in MPFR.

> One might argue that mini-gmp should advertise the same version as the
> gmp release mini-gmp.c was bundled with. But I doubt that's useful; I
> expect these constants to be used mainly for API compatibility things,
> and mini-gmp is only a subset, not fully compatible.

Agreed (as I've just said above).

> >> #define GMP_NUMB_BITS 64
> It would make sense to have this (and GMP_LIMB_BITS) in mini-gmp.h. But
> the definition (which must be portable and not depending on configure)
> is
> #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
> which depends on <limits.h>. And unlike GMP's definition, it's not a
> preprocessor constant, so it's not a fully compatible substitute (#if
> GMP_LIMB_BITS == 64 won't work with mini-gmp).
> If you need a preprocessor constant, I think it has to be defined (or
> redefined) outside of mini-gmp.h.

Yes, we need a preprocessor constant. But we could have a configure
test (run if --enable-mini-gmp was used) to define it.

Vincent Lefèvre <vincent at> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-devel mailing list