Different zlib CRC Algorithms

Wolfgang Denk wd at denx.de
Tue Feb 4 12:17:55 EST 2003


In message <200302041644.40551.phil at river-bank.demon.co.uk> you wrote:
>
> Why does ppcboot/uboot have two versions of crc32()? What's the difference 
> between them?

Quote from U-Boot's "lib_generic/crc32.c":

uLong ZEXPORT crc32(crc, buf, len)
...
    crc = crc ^ 0xffffffffL;
...
    return crc ^ 0xffffffffL;
}   
...
/* No ones complement version. JFFS2 (and other things ?)
 * don't use ones compliment in their CRC calculations.
 */ 
uLong ZEXPORT crc32_no_comp(uLong crc, const Bytef *buf, uInt len)
{   
...
    return crc;
}   


The difference is the "^ 0xffffffffL" part;  if  this  justifies  the
existence  of  another  function  is  another  question  (it would be
trivial to hide this is a macro or such).

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
To program is to be.




More information about the linux-mtd mailing list