How large are arbitrarily large integers? (Was Re: Bitfield subtlety)
Richard Biener
rguenther at suse.de
Thu Mar 29 10:12:32 UTC 2018
On Thu, 29 Mar 2018, Niels Möller wrote:
> Richard Biener <rguenther at suse.de> writes:
>
> > I would be surprised if that wouldn't work everywhere - any reason
> > you have doubts? To clarify, allocation would work like
> >
> > void *ptr = malloc (... + sizeof (size_t));
> > ->_mp_d = (char *)ptr + sizeof (size_t);
> > size_t *size = ptr;
>
> That would give bad alignment in the case that limbs are 64 bits but
> size_t only 32 bits (and the x86_64 "x32" abi is something like that,
> right?).
Yes. Make it
->_mp_d = (char *)ptr + MAX(sizeof (size_t), alignof (limb_t));
and adjust the access accordingly.
Richard.
> Regards,
> /Niels
>
>
--
Richard Biener <rguenther at suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
More information about the gmp-devel
mailing list