[PATCH] mini-gmp: Use long long limb on WIN64
marco.bodrato at tutanota.com
marco.bodrato at tutanota.com
Sat Feb 21 18:37:10 CET 2026
Ciao,
21 feb 2026, 14:04 da hahnjo at hahnjo.de:
> On Tue, 2026-02-17 at 14:56 +0100, marco.bodrato at tutanota.com wrote:
>
>>
>> Ciao,
>>
>
> Hi Marco,
>
> I'm not sure if you wanted to reply privately to me only, or forgot to
> keep gmp-devel in CC... In any case, feel free to forward my reply
> below to the mailing list if relevant.
>
You are right, I reply again to the list.
>> 17 feb 2026, 10:49 da hahnjo at hahnjo.de:
>> > +#ifdef _WIN64
>> > +/* On Windows, long is always 32 bits even on 64-bit */
>> > +#define MINI_GMP_LIMB_TYPE long long
>> Yes, the current mini-gmp and mini-mpq code are designed to work with
>> both larger (long long) and smaller (short, or char, ...) limb types,
>> compared to the _ui type: unsigned long int.
>>
>
> ... which is super useful, but sometimes client code makes assumptions
> that mp_limb_t has a certain range and can be used to pass arguments
> directly to the low-level mpn_ functions.
>
Can I comment that from my point of view this is a bug on that code side? At least a portability bug.All the work to adapt mini-gmp to work with different limb sizes was started by Paul Zimmermam, to test the MPFR library more deeply. Their library is now both more robust on the portability side, and more tested.
>> But it's better to avoid filling that code with lots of exceptions
>> due to the different behavior of different systems.
>>
>
> I think realistically there are two relevant 64-bit systems today:
> LP64, which works fine using long, and LLP64 (basically only WIN64)
> where long is still 32 bits. Taking into account ILP32 for (I think)
> all current 32-bit platforms, this makes WIN64 the only exception that
> needs "long long" instead of "long" to get a limb type equivalent to
> the native pointer size.
>
>> Of course one can add the lines you propose to one's own code, before
>> including mini-gmp.h.
>>
>
> Yes, and that's what I'm proposing for Guile:
> https://codeberg.org/guile/guile/pulls/86
>
I see, and you propose to store an unmodified copy of GMP's files and to wrap them for Guile, a very clean solution in my opinion.
> However, I considered it useful to submit the change upstream to get
> "equivalent" limb types by default. Of course up to you whether that is
> something you want to pursue.
>
Thanks for the proposal.
Ĝis,
mb
More information about the gmp-devel
mailing list