[GRASS-dev] configure: testing arch endian
Brad Douglas
rez at touchofmadness.com
Sun May 7 23:41:35 EDT 2006
On Mon, 2006-05-08 at 14:48 +1200, Hamish 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().
>
> what's so bad about that? If it's in a loop or somewhere where it will
> be a performance hit just save the result to a variable at the start of
> the module.
In the interest of simplification and code reduction...
> > 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?
>
> what about the case of "universal" binaries on OSX, where the endianness
> at run time is not necessarily the endianness at configure/compile time?
http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html
According to Apple, we should be including <endian.h> and test
__BIG_ENDIAN or __LITTLE_ENDIAN. That's even simpler. Everything is
handled by the '--host=', '--build=', and '--target=' configure
switches.
Maybe change G_is_little_endian() to something like this?
{
#ifdef __LITTLE_ENDIAN
return 1;
#elif __BIG_ENDIAN
return 0;
#else /* probably redundant case */
return -1;
#endif
}
--
Brad Douglas <rez touchofmadness com> KB8UYR
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785
More information about the grass-dev
mailing list