Additional memory handler features.

Niels Möller nisse at
Sun Jan 4 15:50:27 UTC 2015

Marc Glisse <marc.glisse at> writes:

> Er, people have been using the custom allocators for (possibly
> imperfect) recovery on allocation failure for years. PPL's configure
> script complains if gmp was compiled without -fexceptions for that
> reason. Apparently SWI-Prolog uses longjmp
> (

Ok, good to hear about some examples. We ought to investigate these
before deciding what to do to improve error recovery hooks.

> Although itch/scratch may force a compromise between overestimating
> the space required or spending too long estimating it, which I hope
> won't penalize small numbers too much.

I think a typical itch function will look like

  foo_itch (mp_size_t n)
      return n; /* Or possibly zero or some other constant */
      ... something possibly more complicated, perhaps
          a full "synthetic computation" ...

So it's a function call (I think we usually want to avoid macros here),
but for small operands it's just the function call overhead and a
well-predicted branch.


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

More information about the gmp-devel mailing list