[Zlib-devel] crc32 big/little endian

Mark Adler madler at alumni.caltech.edu
Wed Apr 21 10:05:47 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 (e.g. PowerPC) can change their endianess while running!  The cost of keeping both sets of code and tables is very small, and detecting endianess at run time is highly reliable and takes negligible time.  If an application really 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.

Mark





More information about the Zlib-devel mailing list