mini-gmp
Vincent Lefevre
vincent at vinc17.net
Sat Dec 15 09:08:12 UTC 2018
On 2018-12-15 09:48:41 +0100, Niels Möller wrote:
> paul zimmermann <Paul.Zimmermann at inria.fr> writes:
>
> > would it be possible to move the following from mini-gmp.c to mini-gmp.h?
> >
> > #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
> >
> > It would expose GMP_LIMB_BITS to applications using mini-gmp,
> > without requiring them to redefine it.
>
> The reason it's not already in mini-gmp.h, is that I'd expect
> applications to want to do things like
>
> #if GMP_LIMB_BITS == 64
> ...
> #endif
Yes, this is expected by MPFR. But since mini-gmp.c includes
mini-gmp.h, this prevents one from redefining GMP_LIMB_BITS
in mini-gmp.h, except by exactly the same content, which is
not interesting.
I suggest either:
#undef GMP_LIMB_BITS
#define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
in order to allow the redefinition in case it was already defined,
or
#ifndef GMP_LIMB_BITS
#define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
#endif
The latter one is better, IMHO, in the rare case
(sizeof(mp_limb_t) * CHAR_BIT) was a wrong guess.
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the gmp-devel
mailing list