[Zlib-devel] crc32 big/little endian
Joakim Tjernlund
joakim.tjernlund at transmode.se
Wed Apr 21 10:48:07 EDT 2010
>
> On Apr 21, 2010, at 6:49 AM, Joakim Tjernlund wrote:
> > Surely it should be enough to detect endian at compile
> > time and only compile the one needed for that particular CPU?
>
> It can't be detected at compile time when cross-compiling, and some processors
Sure you can, use #ifdef __BYTE_ORDER == __BIG_ENDIAN like any
other app does.
> (e.g. PowerPC) can change their endianess while running! The cost of keeping
In what OS would ppc do that? Never seen one and I haven't seen any app endian
dependent app support such things.
> both sets of code and tables is very small, and detecting endianess at run
I don't think 16KB+ as small overhead, it is a lot.
> time is highly reliable and takes negligible time. If an application really
Yes, but so is
#ifndef __BYTE_ORDER
#error byte_order not defined!
#elif __BYTE_ORDER == __BIG_ENDIAN
#warning BIG endian
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#warning LITTLE endian
#endif
> cares about that level of memory usage, they can modify the code and keep only
> the part they need. Or they can define NOBYFOUR and make the code even
> smaller with a 1K table and no endian-dependant code.
It would be better if there are any freak OS out there that can change endian on
the fly define NOBYFOUR instead of making all the rest suffer.
>
> Mark
More information about the Zlib-devel
mailing list