CRC32 functions in libbb

Rob Sullivan cogito.ergo.cogito at gmail.com
Mon Apr 10 08:52:38 UTC 2006


>Moving table generation out of line makes a certain amount of sense.
>Moving the actual crc calculation out of line has a speed hit in code that
>actually tends to care about that...

There seems to be a definite speed hit when the actual CRC calculation is
passed onto bb_crc32_calc, and to be honest, I'm not sure it's worth it in
the first place - bb_crc32_calc basically amounts to:

while (len--) {
                if (endian)
                        crc = crc_table[(crc >> 24) ^ (*data++)] ^ (crc <<
8);
                else
                        crc = crc_table[(crc ^ (*data++)) & 0xFFUL] ^ (crc
>> 8);
        }

which seems too small to be worth a function call, IMHO.

So, I've implemented the use of bb_crc32_filltable, and removed
bb_crc32_calc. While poking around, I found out that decompress_unzip.c has
code duplicated from gzip.c, giving me another CRC table implementation to
replace :) rx.c has some CRC code too, but that calculates a CRC16, so I've
left it.

Patch attached.

> Other Rob
Rob (very tempted to say "the one and only", but I'm sure you send far more
emails to this list than I do, so...)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20060410/0105f193/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crc32.patch
Type: text/x-patch
Size: 6657 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060410/0105f193/attachment.bin 


More information about the busybox mailing list