[postgis-devel] getPoint aligned/unaligned reads
Sandro Santilli
strk at kbt.io
Sun Sep 26 13:20:09 PDT 2021
On Sun, Sep 26, 2021 at 01:01:56PM -0700, Paul Ramsey wrote:
>
>
> > On Sep 26, 2021, at 11:32 AM, Sandro Santilli <strk at kbt.io> wrote:
> >
> > I must have lost track but.. is POINTARRAY nowadays ensured to always
> > be double-aligned or not ? I'm asking because of issue #4990 which
> > reveals some problem on 32bit and I suspect (but didn't confirm yet)
> > that it may be due to using the getPoint_cp function, which does
> > the cast from char* to double*...
>
> Since 2.0 the underlying double array in a POINTARRAY is double aligned, which is the reason getPoint2d_cp() works at all on platforms that disallow unaligned access (hard to find those nowadays though).
>
> > Paul: as the last one who touched the serialization format, is it
> > always safe to use getPoint_cp or not, to your knowledge ?
>
> It is always safe, the serialization is carefully set up to retain double alignment of the double arrays.
Ok, thank you. Then I guess all occurrences of getPoint_p could
probably be converted to getPoint_cp for some speedup.
And it also means my bug is not related to alignment :(
--strk;
More information about the postgis-devel
mailing list