aboutsummaryrefslogtreecommitdiff
path: root/archival/lzop.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-10-27 15:26:45 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-10-27 15:26:45 +0200
commit9ce642f9746dfc29d119d0680b769677e3ea6da6 (patch)
treef8d2bcd08c691979058b610b32573a742a3e3024 /archival/lzop.c
parentdd88ba88f5082b1785539b1fb87af7320515b8c9 (diff)
downloadbusybox-w32-9ce642f9746dfc29d119d0680b769677e3ea6da6.tar.gz
busybox-w32-9ce642f9746dfc29d119d0680b769677e3ea6da6.tar.bz2
busybox-w32-9ce642f9746dfc29d119d0680b769677e3ea6da6.zip
libbb: introduce and use common crc32 routine
function old new delta crc32_block_endian1 - 37 +37 crc32_block_endian0 - 34 +34 global_crc32_table - 8 +8 file_read 82 87 +5 gzip_main 211 214 +3 xz_crc32 40 35 -5 crc32_table 8 - -8 calculate_gunzip_crc 54 34 -20 lzo_crc32 54 25 -29 cksum_main 298 211 -87 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 2/4 up/down: 87/-149) Total: -62 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'archival/lzop.c')
-rw-r--r--archival/lzop.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/archival/lzop.c b/archival/lzop.c
index c6e718ad7..acb34fe14 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -393,7 +393,7 @@ typedef struct header_t {
393} header_t; 393} header_t;
394 394
395struct globals { 395struct globals {
396 const uint32_t *lzo_crc32_table; 396 /*const uint32_t *lzo_crc32_table;*/
397 chksum_t chksum_in; 397 chksum_t chksum_in;
398 chksum_t chksum_out; 398 chksum_t chksum_out;
399} FIX_ALIASING; 399} FIX_ALIASING;
@@ -468,19 +468,10 @@ lzo_adler32(uint32_t adler, const uint8_t* buf, unsigned len)
468static FAST_FUNC uint32_t 468static FAST_FUNC uint32_t
469lzo_crc32(uint32_t c, const uint8_t* buf, unsigned len) 469lzo_crc32(uint32_t c, const uint8_t* buf, unsigned len)
470{ 470{
471 uint32_t crc; 471 //if (buf == NULL) - impossible
472 // return 0;
472 473
473 if (buf == NULL) 474 return ~crc32_block_endian0(~c, buf, len, global_crc32_table);
474 return 0;
475
476 crc = ~c;
477 if (len != 0) do {
478 crc = G.lzo_crc32_table[(uint8_t)((int)crc ^ *buf)] ^ (crc >> 8);
479 buf += 1;
480 len -= 1;
481 } while (len > 0);
482
483 return ~crc;
484} 475}
485 476
486/**********************************************************************/ 477/**********************************************************************/
@@ -679,8 +670,7 @@ static NOINLINE smallint lzo_compress(const header_t *h)
679 if (dst_len < src_len) { 670 if (dst_len < src_len) {
680 /* write checksum of compressed block */ 671 /* write checksum of compressed block */
681 if (h->flags & F_ADLER32_C) 672 if (h->flags & F_ADLER32_C)
682 write32(lzo_adler32(ADLER32_INIT_VALUE, b2, 673 write32(lzo_adler32(ADLER32_INIT_VALUE, b2, dst_len));
683 dst_len));
684 if (h->flags & F_CRC32_C) 674 if (h->flags & F_CRC32_C)
685 write32(lzo_crc32(CRC32_INIT_VALUE, b2, dst_len)); 675 write32(lzo_crc32(CRC32_INIT_VALUE, b2, dst_len));
686 /* write compressed block data */ 676 /* write compressed block data */
@@ -1080,6 +1070,6 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
1080 if (applet_name[0] == 'u') 1070 if (applet_name[0] == 'u')
1081 option_mask32 |= OPT_DECOMPRESS; 1071 option_mask32 |= OPT_DECOMPRESS;
1082 1072
1083 G.lzo_crc32_table = crc32_filltable(NULL, 0); 1073 global_crc32_table = crc32_filltable(NULL, 0);
1084 return bbunpack(argv, pack_lzop, make_new_name_lzop, /*unused:*/ NULL); 1074 return bbunpack(argv, pack_lzop, make_new_name_lzop, /*unused:*/ NULL);
1085} 1075}