support larger int types
Ulrich Drepper
drepper at gmail.com
Thu Oct 13 13:30:44 UTC 2016
On Wed, Oct 12, 2016 at 6:24 PM, Marc Glisse <marc.glisse at inria.fr> wrote:
> - there were plans to completely decouple the limb size from the size of
> long (the argument of mpz_*_si), so the same code could be used for
> different sizes (and so we could play with arbitrary limb sizes).
And having the various *_iNN and *_uNN should then be a boost and not
a negative, no?
> - the ABI should be relatively stable, the list of functions provided by
> libgmp should not be too random depending on the exact compiler and options
> used to build it.
Yep, I see that. Especially with the extended types. But this lowest
common denominator rule is holding back development.
> - I believe GMP still doesn't require a C99 compiler.
Except for passing of 64-bit numbers with some 32-bit compilers this
should not be an issue. The __int128 types are not in C99 or even C14
and therefore any support like this would go beyond standrd C anyway.
> (at some point, I was tempted to add long long support in the C++ wrapper,
> where it is easier because overloading and inlining avoid most ABI
> complications)
That would work for me as well. It should be much less controversial.
> What does your interface look like? 2 new functions mpz_set_si128 and
> mpz_set_ui128?
Exactly the names I chose.
> Or did you also add fits_* and get_* functions? Or even the
> mixed operations like mpz_add_si128?
I have a growing number of these interfaces. So far I have setters,
comparison and arithmetic with integers, for mpz and mpq. Not a
complete set yet, since I don't need it so far, but simple versions
can be written fairly quickly.
> I assume an autoconf test would determine if the functions are compiled. In
> gmp.h, would we test the macro __SIZEOF_INT128__, or would we hard-code the
> result from autoconf?
Well, if the __int128 is not compiled in you cannot test macros in the
headers. So, the configure decision has to be remembered. In
addition __SIZEOF_INT128__ has to be checked at compile-time in case a
different compiler is used.
I can prepare an initial patch if there is consensus that such a
change is wanted. It might take a bit, travel and other projects.
The code I wrote so far certainly needs to be adapted to the GMP
format.
More information about the gmp-discuss
mailing list