aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/gzip.c16
-rw-r--r--archival/libunarchive/decompress_unxz.c14
-rw-r--r--archival/libunarchive/decompress_unzip.c5
-rw-r--r--archival/lzop.c22
4 files changed, 15 insertions, 42 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index e9f09730d..ffae9751b 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -340,7 +340,7 @@ struct globals {
340 ulg bits_sent; /* bit length of the compressed data */ 340 ulg bits_sent; /* bit length of the compressed data */
341#endif 341#endif
342 342
343 uint32_t *crc_32_tab; 343 /*uint32_t *crc_32_tab;*/
344 uint32_t crc; /* shift register contents */ 344 uint32_t crc; /* shift register contents */
345}; 345};
346 346
@@ -393,15 +393,9 @@ static void put_32bit(ulg n)
393 * pointer, then initialize the crc shift register contents instead. 393 * pointer, then initialize the crc shift register contents instead.
394 * Return the current crc in either case. 394 * Return the current crc in either case.
395 */ 395 */
396static uint32_t updcrc(uch * s, unsigned n) 396static void updcrc(uch * s, unsigned n)
397{ 397{
398 uint32_t c = G1.crc; 398 G1.crc = crc32_block_endian0(G1.crc, s, n, global_crc32_table /*G1.crc_32_tab*/);
399 while (n) {
400 c = G1.crc_32_tab[(uch)(c ^ *s++)] ^ (c >> 8);
401 n--;
402 }
403 G1.crc = c;
404 return c;
405} 399}
406 400
407 401
@@ -2104,8 +2098,8 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
2104 ALLOC(uch, G1.window, 2L * WSIZE); 2098 ALLOC(uch, G1.window, 2L * WSIZE);
2105 ALLOC(ush, G1.prev, 1L << BITS); 2099 ALLOC(ush, G1.prev, 1L << BITS);
2106 2100
2107 /* Initialise the CRC32 table */ 2101 /* Initialize the CRC32 table */
2108 G1.crc_32_tab = crc32_filltable(NULL, 0); 2102 global_crc32_table = crc32_filltable(NULL, 0);
2109 2103
2110 return bbunpack(argv, pack_gzip, append_ext, "gz"); 2104 return bbunpack(argv, pack_gzip, append_ext, "gz");
2111} 2105}
diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c
index faba9ca82..ca427231e 100644
--- a/archival/libunarchive/decompress_unxz.c
+++ b/archival/libunarchive/decompress_unxz.c
@@ -22,17 +22,9 @@
22 22
23/* We use our own crc32 function */ 23/* We use our own crc32 function */
24#define XZ_INTERNAL_CRC32 0 24#define XZ_INTERNAL_CRC32 0
25static uint32_t *crc32_table;
26static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) 25static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
27{ 26{
28 crc = ~crc; 27 return ~crc32_block_endian0(~crc, buf, size, global_crc32_table);
29
30 while (size != 0) {
31 crc = crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
32 --size;
33 }
34
35 return ~crc;
36} 28}
37 29
38/* We use arch-optimized unaligned accessors */ 30/* We use arch-optimized unaligned accessors */
@@ -53,8 +45,8 @@ unpack_xz_stream(int src_fd, int dst_fd)
53 unsigned char *membuf; 45 unsigned char *membuf;
54 IF_DESKTOP(long long) int total = 0; 46 IF_DESKTOP(long long) int total = 0;
55 47
56 if (!crc32_table) 48 if (!global_crc32_table)
57 crc32_table = crc32_filltable(NULL, /*endian:*/ 0); 49 global_crc32_table = crc32_filltable(NULL, /*endian:*/ 0);
58 50
59 memset(&iobuf, 0, sizeof(iobuf)); 51 memset(&iobuf, 0, sizeof(iobuf));
60 /* Preload XZ file signature */ 52 /* Preload XZ file signature */
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 20fda9d26..cb8a3d737 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -925,10 +925,7 @@ static int inflate_block(STATE_PARAM smallint *e)
925/* Two callsites, both in inflate_get_next_window */ 925/* Two callsites, both in inflate_get_next_window */
926static void calculate_gunzip_crc(STATE_PARAM_ONLY) 926static void calculate_gunzip_crc(STATE_PARAM_ONLY)
927{ 927{
928 unsigned n; 928 gunzip_crc = crc32_block_endian0(gunzip_crc, gunzip_window, gunzip_outbuf_count, gunzip_crc_table);
929 for (n = 0; n < gunzip_outbuf_count; n++) {
930 gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
931 }
932 gunzip_bytes_out += gunzip_outbuf_count; 929 gunzip_bytes_out += gunzip_outbuf_count;
933} 930}
934 931
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}