Small limb-size in mini-gmp?

Niels Möller nisse at lysator.liu.se
Sun Nov 10 08:43:10 UTC 2019


Hi,

I noticed the recent change
https://gmplib.org/repo/gmp/rev/d5f4f8640be9, "mini-gmp: Avoid undefined
behaviour with small limb sizes."

Currently, mini-gmp.h makes mp_limb_t an alias for unsigned long, which
by the C spec ought to be at least 32 bits. And then, e.g.,

  int LOCAL_SHIFT_BITS = 16;
  ...
  if (sizeof(mp_limb_t) * CHAR_BIT > LOCAL_SHIFT_BITS)

ought to be always true. Are you planning to do something like
artificial-small-limbs for mini-gmp, suggested on the list a while ago?

Also,

  if (GMP_LIMB_BITS > LOCAL_SHIFT_BITS)

should be equivalent, and slightly more readable, imo.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.



More information about the gmp-devel mailing list