[PATCH] mini-gmp: Use long long limb on WIN64

Jonas Hahnfeld hahnjo at hahnjo.de
Mon Mar 2 22:31:11 CET 2026


On Sun, 2026-03-01 at 10:36 +0100, marco.bodrato at tutanota.com wrote:
> 22 feb 2026, 21:53 da hahnjo at hahnjo.de:
> > I wonder if
> > there's an "established" pattern if mp_limb_t is not sufficient for the
> > value at hand? Ideally without allocating dynamic memory.
> 
> I'd say something like the following (but I did not test the code):
> 
> mpz_t initOnceUseMany;
> mpz_init2 (initOnceUseMany, sizeof(unsigned long) * CHAR_BIT);
> 
> for (unsigned int value = 123; value < 987654; value +=357)
> {
>   mp_srcptr ptr;
>   mp_size_t siz;
>   mpz_set_ui (initOnceUseMany, value);
>   siz = mpz_size (initOnceUseMany);
>   ptr = mpz_limbs_read (initOnceUseMany);
>   /* code using the mpn pointed by ptr, with size siz as a read-only value. */
> }
> 
> mpz_clear (initOnceUseMany);
> 
> ...unfortunately, this approach only works with unsigned long and smaller
> types, but your problem arises where unsigned long is not long enough...

Yes, that's one problem. I would also be hard to reuse mpz_t, there are
many one-off uses in internal functions. Which is currently not an
issue because it doesn't allocate...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <https://gmplib.org/list-archives/gmp-devel/attachments/20260302/23379923/attachment.bin>


More information about the gmp-devel mailing list