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

marco.bodrato at tutanota.com marco.bodrato at tutanota.com
Sun Mar 1 10:36:01 CET 2026


Ciao Jonas,

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...

Ĝis,
mb


More information about the gmp-devel mailing list