[postgis-devel] getPoint aligned/unaligned reads

Paul Ramsey pramsey at cleverelephant.ca
Sun Sep 26 13:21:15 PDT 2021



> On Sep 26, 2021, at 1:20 PM, Sandro Santilli <strk at kbt.io> wrote:
> 
> 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.

I feel like most of these have been done over the years, but yes, when you're just doing 2d read-only access, it's a freebie.

P.

> 
> And it also means my bug is not related to alignment :(
> 
> --strk;
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list