_mp_alloc to long int

Simon Sobisch simonsobisch at gnu.org
Tue Aug 23 13:04:45 CEST 2022


> Date: Mon, 22 Aug 2022 17:11:25 +0200
> From: Paul Zimmermann <Paul.Zimmermann at inria.fr>
> To: Roman Savelyev <rsavelyev at wlu.ca>
> Cc: gmp-discuss at gmplib.org
> Subject: Re: _mp_alloc to long int
> Message-ID: <mwo7wcnwiq.fsf at tomate.loria.fr>
> Content-Type: text/plain; charset=utf-8
>
>> From: Roman Savelyev <rsavelyev at wlu.ca>
>> Thread-Topic: _mp_alloc to long int
>> Thread-Index: AQHYo23PcvMGd5LgN0yv6fOgqbtKKg==
>> Date: Fri, 29 Jul 2022 17:12:18 +0000
>>
>> A project I am working on, requires more than 2^37 limbs, more than a 64 bit system would allow, if mp_alloc is set to int. When I manually change it to long int, recompile and run, I get a segmentation fault, particularly in mpz_set_ui through gmpxx. Would you be willing to shine a light on what needs to change within the program to make it possible to make this change?
>> _______________________________________________
>> gmp-discuss mailing list
>> gmp-discuss at gmplib.org
>> https://gmplib.org/mailman/listinfo/gmp-discuss
>>
> in gmp-h.in, change the _mp_alloc and _mp_size fields from 'int' to 'long';
> in mpz/init2.c, change 'int' to 'long' on line 43, and INT_MAX to LONG_MAX
> 2 lines later, and do similar changes in mpz/realloc.c and mpz/realloc2.c.
>
> This is the "gmp enterprise" patch from my colleague Emmanuel Thom?
> (https://gmplib.org/list-archives/gmp-devel/2018-March/004817.html).
>
> Paul

Can this be made a "permanent" patch by defining a type (and its max) in 
gmp-h.in (by default to "int / INT_MAX" and using this in all those places)?
That seems to be "clean" in any case.

To make that more useful a configure flag may be added _later_ which 
does the change of the typedef from "int" to "long" and activates a set 
of more tests using huge values.

... just thinking ...



More information about the gmp-discuss mailing list