nisse at lysator.liu.se
Sat Dec 15 08:48:41 UTC 2018
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
Which works with the real GMP. But it does *not* work with the above
definition, since the preprocessor doesn't know how to evaluate sizeof.
And I'm not aware of any standard preprocessor constants that could be
used instead. I guess one *could* try to evaluate log_2(ULONG_MAX) in
the preprocessor using a long sequence of conditionals, but that's not
In Nettle, where I need GMP_NUMB_BITS both for a few #ifdefs in the C
code, and to run programs to generate ECC tables, I use a configure
check do get the correct value (correct also when cross compiling,
thanks to autoconf's clever implementation of AC_COMPUTE_INT). See
If anyone knows a good way to define it as a preprocessor constant
without a configure check, that would be great.
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel