[GRASS-dev] configure: testing arch endian

William Kyngesburye woklist at kyngchaos.com
Mon May 8 10:25:34 EDT 2006


I agree - at least that endian checking should be done at runtime, if  
the program needs to know.  From my point of view:

Mac OS X PPC/Intel universal binaries.  You can build a universal  
binary in one go, by adding dual -arch options to all compile and  
link commands.  This works just fine for any Mac application, they  
don't have endian issues, and Apple has some info on writing endian- 
independent code.  But when endian is set during configure for that  
build, it's fixed for the architecture you're building on (say PPC),  
and the other arch's (Intel, then) build is broken.

What I end up doing then is config-make for my arch.  Config another  
copy and hack eny endian settings to the other arch, make that.  Lipo  
the two together.  I actually replace endian settings with a test for  
a macro that I supply at build time, so I can toggle all installed  
dependency headers (defaults to big-endian for now).


On May 7, 2006, at 11:06 PM, Glynn Clements wrote:

>
> Brad Douglas wrote:
>
>> I would like to add a macro into aclocal.m4/configure.in to test for
>> architecture byte order.  This would then define something like
>> G_BIGENDIAN 0/1 in include/config.h.in.
>>
>> I think this would be better than testing for it constantly with
>> G_is_little_endian().  This would also keep it from being  
>> reimplemented
>> in libraries that are not interdependent (eg. lib/gis,
>> lib/vector/dglib).
>>
>> I noticed that endian is not even considered in lib/image.  I'll fix
>> that if I get the clear for the above (or some reversion of).
>>
>> Comments?  Caveats?
>
> Personally, I would suggest just writing code which doesn't rely upon
> the system's byte order; i.e. explicitly convert byte-arrays to words
> using left-shift+OR and vice-versa using right-shift+AND.
>

-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/

"Oh, look, I seem to have fallen down a deep, dark hole.  Now what  
does that remind me of?  Ah, yes - life."

- Marvin




More information about the grass-dev mailing list