[postgis-devel] Determining Endianess
Paul Ramsey
pramsey at refractions.net
Mon Feb 9 10:57:31 PST 2004
Better to just find out where postgresql computes it and take it from
there. We should not be testing for endianness at runtime.
strk wrote:
> I've included your code in pgsql2shp.
> It would be needed for postgis_inout.c
> and postgis_gist*.c where its computation
> time will be more noticeable.
>
> I've asked to the pgsql-hackers about using their computed
> BYTE_ORDER. Yet, I'd see better having Dave's code as an m4 macro
> and postgis switch to autoconf.
>
> dblasby wrote:
>
>>Here's a piece of code that directly tests the endian of the machine.
>>Basically, it looks at how the number 1 is stored. In the 4 byte int,
>>if its NDR, it will be in the 1st byte. If its XDR, it'll be in the
>>last byte.
>>
>> int test = 1;
>>
>> if ( (((char *)(&test))[0]) == 1)
>> {
>> //NDR
>> }
>> else
>> {
>> //XDR
>> }
>>
>>_______________________________________________
>>postgis-devel mailing list
>>postgis-devel at postgis.refractions.net
>>http://postgis.refractions.net/mailman/listinfo/postgis-devel
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
--
__
/
| Paul Ramsey
| Refractions Research
| Email: pramsey at refractions.net
| Phone: (250) 885-0632
\_
More information about the postgis-devel
mailing list