aboutsummaryrefslogtreecommitdiff
path: root/archival/gzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/gzip.c')
-rw-r--r--archival/gzip.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index 6083cde88..7df38c2bc 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -486,19 +486,26 @@ static void put_16bit(ush w)
486#define OPTIMIZED_PUT_32BIT (CONFIG_GZIP_FAST > 0 && BB_UNALIGNED_MEMACCESS_OK && BB_LITTLE_ENDIAN) 486#define OPTIMIZED_PUT_32BIT (CONFIG_GZIP_FAST > 0 && BB_UNALIGNED_MEMACCESS_OK && BB_LITTLE_ENDIAN)
487static void put_32bit(ulg n) 487static void put_32bit(ulg n)
488{ 488{
489#if OPTIMIZED_PUT_32BIT 489 if (OPTIMIZED_PUT_32BIT) {
490 unsigned outcnt = G1.outcnt; 490 unsigned outcnt = G1.outcnt;
491 if (outcnt < OUTBUFSIZ-4) { 491 if (outcnt < OUTBUFSIZ-4) {
492 /* Common case */ 492 /* Common case */
493 ulg *dst32 = (void*) &G1.outbuf[outcnt]; 493 ulg *dst32 = (void*) &G1.outbuf[outcnt];
494 *dst32 = n; /* unaligned LSB 32-bit store */ 494 *dst32 = n; /* unaligned LSB 32-bit store */
495 G1.outcnt = outcnt + 4; 495 //bb_error_msg("%p", dst32); // store alignment debugging
496 return; 496 G1.outcnt = outcnt + 4;
497 return;
498 }
497 } 499 }
498#endif
499 put_16bit(n); 500 put_16bit(n);
500 put_16bit(n >> 16); 501 put_16bit(n >> 16);
501} 502}
503static ALWAYS_INLINE void flush_outbuf_if_32bit_optimized(void)
504{
505 /* If put_32bit() performs 32bit stores && it is used in send_bits() */
506 if (OPTIMIZED_PUT_32BIT && BUF_SIZE > 16)
507 flush_outbuf();
508}
502 509
503/* =========================================================================== 510/* ===========================================================================
504 * Run a set of bytes through the crc shift register. If s is a NULL 511 * Run a set of bytes through the crc shift register. If s is a NULL
@@ -626,6 +633,8 @@ static void copy_block(char *buf, unsigned len, int header)
626 while (len--) { 633 while (len--) {
627 put_8bit(*buf++); 634 put_8bit(*buf++);
628 } 635 }
636 /* The above can 32-bit misalign outbuf */
637 flush_outbuf_if_32bit_optimized();
629} 638}
630 639
631 640
@@ -2110,12 +2119,8 @@ static void zip(void)
2110 2119
2111 put_16bit(deflate_flags | 0x300); /* extra flags. OS id = 3 (Unix) */ 2120 put_16bit(deflate_flags | 0x300); /* extra flags. OS id = 3 (Unix) */
2112 2121
2113#if OPTIMIZED_PUT_32BIT 2122 /* The above 32-bit misaligns outbuf (10 bytes are stored), flush it */
2114 /* put_32bit() performs 32bit stores. If we use it in send_bits()... */ 2123 flush_outbuf_if_32bit_optimized();
2115 if (BUF_SIZE > 16)
2116 /* then all stores are misaligned, unless we flush the buffer now */
2117 flush_outbuf();
2118#endif
2119 2124
2120 deflate(); 2125 deflate();
2121 2126