diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-10 13:25:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-10 13:25:57 +0200 |
commit | 522041ee7b10ac544b90c6a8d1d4fbf8a5d39c6d (patch) | |
tree | 412854af83f841f564faf842ca6cefc12a016236 | |
parent | 202a1b9284fd763e81340050d228103aef999675 (diff) | |
download | busybox-w32-522041ee7b10ac544b90c6a8d1d4fbf8a5d39c6d.tar.gz busybox-w32-522041ee7b10ac544b90c6a8d1d4fbf8a5d39c6d.tar.bz2 busybox-w32-522041ee7b10ac544b90c6a8d1d4fbf8a5d39c6d.zip |
regularize options which control size/speed trade
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/Config.src | 27 | ||||
-rw-r--r-- | archival/bzip2.c | 4 | ||||
-rw-r--r-- | archival/gzip.c | 8 | ||||
-rw-r--r-- | archival/libarchive/bz/blocksort.c | 8 | ||||
-rw-r--r-- | archival/libarchive/bz/bzlib_private.h | 2 | ||||
-rw-r--r-- | archival/libarchive/bz/compress.c | 8 | ||||
-rw-r--r-- | archival/libarchive/bz/huffman.c | 2 | ||||
-rw-r--r-- | configs/TEST_nommu_defconfig | 2 | ||||
-rw-r--r-- | configs/TEST_noprintf_defconfig | 2 | ||||
-rw-r--r-- | configs/TEST_rh9_defconfig | 2 | ||||
-rw-r--r-- | configs/android2_defconfig | 2 | ||||
-rw-r--r-- | configs/android_defconfig | 2 | ||||
-rw-r--r-- | configs/cygwin_defconfig | 2 | ||||
-rw-r--r-- | configs/freebsd_defconfig | 2 | ||||
-rw-r--r-- | libbb/Config.src | 4 | ||||
-rw-r--r-- | libbb/hash_md5_sha.c | 32 | ||||
-rw-r--r-- | libbb/hash_md5prime.c | 26 |
17 files changed, 69 insertions, 66 deletions
diff --git a/archival/Config.src b/archival/Config.src index 9f4908178..885cb5bcc 100644 --- a/archival/Config.src +++ b/archival/Config.src | |||
@@ -187,15 +187,17 @@ config FEATURE_GZIP_LONG_OPTIONS | |||
187 | help | 187 | help |
188 | Enable use of long options, increases size by about 106 Bytes | 188 | Enable use of long options, increases size by about 106 Bytes |
189 | 189 | ||
190 | config GZIP_BIG_MEM | 190 | config GZIP_FAST |
191 | bool "Trade memory for gzip speed" | 191 | int "Trade memory for gzip speed (0:small,slow - 2:fast,big)" |
192 | default n | 192 | default 0 |
193 | depends on GZIP | 193 | range 0 2 |
194 | help | 194 | depends on GZIP |
195 | Enable big memory options for gzip, including larger I/O | 195 | help |
196 | buffers and bigger hash tables. Faster, but uses at least | 196 | Enable big memory options for gzip. |
197 | twice as much memory. Select if speed is more important than | 197 | 0: small buffers, small hash-tables |
198 | memory use. | 198 | 1: larger buffers, larger hash-tables |
199 | 2: larger buffers, largest hash-tables | ||
200 | Larger models may give slightly better compression | ||
199 | 201 | ||
200 | config LZOP | 202 | config LZOP |
201 | bool "lzop" | 203 | bool "lzop" |
@@ -340,15 +342,12 @@ config UNLZMA | |||
340 | is generally considerably better than that achieved by the bzip2 | 342 | is generally considerably better than that achieved by the bzip2 |
341 | compressors. | 343 | compressors. |
342 | 344 | ||
343 | The BusyBox unlzma applet is limited to de-compression only. | 345 | The BusyBox unlzma applet is limited to decompression only. |
344 | On an x86 system, this applet adds about 4K. | 346 | On an x86 system, this applet adds about 4K. |
345 | 347 | ||
346 | Unless you have a specific application which requires unlzma, you | ||
347 | should probably say N here. | ||
348 | |||
349 | config FEATURE_LZMA_FAST | 348 | config FEATURE_LZMA_FAST |
350 | bool "Optimize unlzma for speed" | 349 | bool "Optimize unlzma for speed" |
351 | default y | 350 | default n |
352 | depends on UNLZMA | 351 | depends on UNLZMA |
353 | help | 352 | help |
354 | This option reduces decompression time by about 25% at the cost of | 353 | This option reduces decompression time by about 25% at the cost of |
diff --git a/archival/bzip2.c b/archival/bzip2.c index e39d7f704..3dde970f1 100644 --- a/archival/bzip2.c +++ b/archival/bzip2.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include "libbb.h" | 19 | #include "libbb.h" |
20 | #include "archive.h" | 20 | #include "archive.h" |
21 | 21 | ||
22 | #define CONFIG_BZIP2_FEATURE_SPEED 1 | 22 | #define CONFIG_BZIP2_FAST 1 |
23 | 23 | ||
24 | /* Speed test: | 24 | /* Speed test: |
25 | * Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache). | 25 | * Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache). |
@@ -27,7 +27,7 @@ | |||
27 | * (time to compress gcc-4.2.1.tar is 126.4% compared to bbox). | 27 | * (time to compress gcc-4.2.1.tar is 126.4% compared to bbox). |
28 | * At SPEED 5 difference is 32.7%. | 28 | * At SPEED 5 difference is 32.7%. |
29 | * | 29 | * |
30 | * Test run of all CONFIG_BZIP2_FEATURE_SPEED values on a 11Mb text file: | 30 | * Test run of all CONFIG_BZIP2_FAST values on a 11Mb text file: |
31 | * Size Time (3 runs) | 31 | * Size Time (3 runs) |
32 | * 0: 10828 4.145 4.146 4.148 | 32 | * 0: 10828 4.145 4.146 4.148 |
33 | * 1: 11097 3.845 3.860 3.861 | 33 | * 1: 11097 3.845 3.860 3.861 |
diff --git a/archival/gzip.c b/archival/gzip.c index 0e0b68142..3af930b7e 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -81,10 +81,14 @@ aa: 85.1% -- replaced with aa.gz | |||
81 | 81 | ||
82 | /* =========================================================================== | 82 | /* =========================================================================== |
83 | */ | 83 | */ |
84 | #if ENABLE_GZIP_BIG_MEM | 84 | #if CONFIG_GZIP_FAST == 0 |
85 | # define SMALL_MEM | ||
86 | #elif CONFIG_GZIP_FAST == 1 | ||
87 | # define MEDIUM_MEM | ||
88 | #elif CONFIG_GZIP_FAST == 2 | ||
85 | # define BIG_MEM | 89 | # define BIG_MEM |
86 | #else | 90 | #else |
87 | # define SMALL_MEM | 91 | # error "Invalid CONFIG_GZIP_FAST value" |
88 | #endif | 92 | #endif |
89 | 93 | ||
90 | #ifndef INBUFSIZ | 94 | #ifndef INBUFSIZ |
diff --git a/archival/libarchive/bz/blocksort.c b/archival/libarchive/bz/blocksort.c index f70c3701d..e600cb7a7 100644 --- a/archival/libarchive/bz/blocksort.c +++ b/archival/libarchive/bz/blocksort.c | |||
@@ -385,7 +385,7 @@ int mainGtU( | |||
385 | * but speeds up compression 10% overall | 385 | * but speeds up compression 10% overall |
386 | */ | 386 | */ |
387 | 387 | ||
388 | #if CONFIG_BZIP2_FEATURE_SPEED >= 1 | 388 | #if CONFIG_BZIP2_FAST >= 1 |
389 | 389 | ||
390 | #define TIMES_8(code) \ | 390 | #define TIMES_8(code) \ |
391 | code; code; code; code; \ | 391 | code; code; code; code; \ |
@@ -496,7 +496,7 @@ void mainSimpleSort(uint32_t* ptr, | |||
496 | i++; | 496 | i++; |
497 | 497 | ||
498 | /* 1.5% overall speedup, +290 bytes */ | 498 | /* 1.5% overall speedup, +290 bytes */ |
499 | #if CONFIG_BZIP2_FEATURE_SPEED >= 3 | 499 | #if CONFIG_BZIP2_FAST >= 3 |
500 | /*-- copy 2 --*/ | 500 | /*-- copy 2 --*/ |
501 | if (i > hi) break; | 501 | if (i > hi) break; |
502 | v = ptr[i]; | 502 | v = ptr[i]; |
@@ -750,7 +750,7 @@ void mainSort(EState* state, | |||
750 | j = block[0] << 8; | 750 | j = block[0] << 8; |
751 | i = nblock - 1; | 751 | i = nblock - 1; |
752 | /* 3%, +300 bytes */ | 752 | /* 3%, +300 bytes */ |
753 | #if CONFIG_BZIP2_FEATURE_SPEED >= 2 | 753 | #if CONFIG_BZIP2_FAST >= 2 |
754 | for (; i >= 3; i -= 4) { | 754 | for (; i >= 3; i -= 4) { |
755 | quadrant[i] = 0; | 755 | quadrant[i] = 0; |
756 | j = (j >> 8) | (((uint16_t)block[i]) << 8); | 756 | j = (j >> 8) | (((uint16_t)block[i]) << 8); |
@@ -787,7 +787,7 @@ void mainSort(EState* state, | |||
787 | 787 | ||
788 | s = block[0] << 8; | 788 | s = block[0] << 8; |
789 | i = nblock - 1; | 789 | i = nblock - 1; |
790 | #if CONFIG_BZIP2_FEATURE_SPEED >= 2 | 790 | #if CONFIG_BZIP2_FAST >= 2 |
791 | for (; i >= 3; i -= 4) { | 791 | for (; i >= 3; i -= 4) { |
792 | s = (s >> 8) | (block[i] << 8); | 792 | s = (s >> 8) | (block[i] << 8); |
793 | j = ftab[s] - 1; | 793 | j = ftab[s] - 1; |
diff --git a/archival/libarchive/bz/bzlib_private.h b/archival/libarchive/bz/bzlib_private.h index 6430ce407..43e674bec 100644 --- a/archival/libarchive/bz/bzlib_private.h +++ b/archival/libarchive/bz/bzlib_private.h | |||
@@ -183,7 +183,7 @@ typedef struct EState { | |||
183 | /* stack-saving measures: these can be local, but they are too big */ | 183 | /* stack-saving measures: these can be local, but they are too big */ |
184 | int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | 184 | int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
185 | int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | 185 | int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
186 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 | 186 | #if CONFIG_BZIP2_FAST >= 5 |
187 | /* second dimension: only 3 needed; 4 makes index calculations faster */ | 187 | /* second dimension: only 3 needed; 4 makes index calculations faster */ |
188 | uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4]; | 188 | uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4]; |
189 | #endif | 189 | #endif |
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c index f93671742..e9f1afdaf 100644 --- a/archival/libarchive/bz/compress.c +++ b/archival/libarchive/bz/compress.c | |||
@@ -61,7 +61,7 @@ void bsFinishWrite(EState* s) | |||
61 | /*---------------------------------------------------*/ | 61 | /*---------------------------------------------------*/ |
62 | static | 62 | static |
63 | /* Helps only on level 5, on other levels hurts. ? */ | 63 | /* Helps only on level 5, on other levels hurts. ? */ |
64 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 | 64 | #if CONFIG_BZIP2_FAST >= 5 |
65 | ALWAYS_INLINE | 65 | ALWAYS_INLINE |
66 | #endif | 66 | #endif |
67 | void bsW(EState* s, int32_t n, uint32_t v) | 67 | void bsW(EState* s, int32_t n, uint32_t v) |
@@ -331,7 +331,7 @@ void sendMTFValues(EState* s) | |||
331 | for (v = 0; v < alphaSize; v++) | 331 | for (v = 0; v < alphaSize; v++) |
332 | s->rfreq[t][v] = 0; | 332 | s->rfreq[t][v] = 0; |
333 | 333 | ||
334 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 | 334 | #if CONFIG_BZIP2_FAST >= 5 |
335 | /* | 335 | /* |
336 | * Set up an auxiliary length table which is used to fast-track | 336 | * Set up an auxiliary length table which is used to fast-track |
337 | * the common case (nGroups == 6). | 337 | * the common case (nGroups == 6). |
@@ -361,7 +361,7 @@ void sendMTFValues(EState* s) | |||
361 | */ | 361 | */ |
362 | for (t = 0; t < nGroups; t++) | 362 | for (t = 0; t < nGroups; t++) |
363 | cost[t] = 0; | 363 | cost[t] = 0; |
364 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 | 364 | #if CONFIG_BZIP2_FAST >= 5 |
365 | if (nGroups == 6 && 50 == ge-gs+1) { | 365 | if (nGroups == 6 && 50 == ge-gs+1) { |
366 | /*--- fast track the common case ---*/ | 366 | /*--- fast track the common case ---*/ |
367 | register uint32_t cost01, cost23, cost45; | 367 | register uint32_t cost01, cost23, cost45; |
@@ -420,7 +420,7 @@ void sendMTFValues(EState* s) | |||
420 | * Increment the symbol frequencies for the selected table. | 420 | * Increment the symbol frequencies for the selected table. |
421 | */ | 421 | */ |
422 | /* 1% faster compress. +800 bytes */ | 422 | /* 1% faster compress. +800 bytes */ |
423 | #if CONFIG_BZIP2_FEATURE_SPEED >= 4 | 423 | #if CONFIG_BZIP2_FAST >= 4 |
424 | if (nGroups == 6 && 50 == ge-gs+1) { | 424 | if (nGroups == 6 && 50 == ge-gs+1) { |
425 | /*--- fast track the common case ---*/ | 425 | /*--- fast track the common case ---*/ |
426 | #define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++ | 426 | #define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++ |
diff --git a/archival/libarchive/bz/huffman.c b/archival/libarchive/bz/huffman.c index 676b1af66..bbec11adb 100644 --- a/archival/libarchive/bz/huffman.c +++ b/archival/libarchive/bz/huffman.c | |||
@@ -48,7 +48,7 @@ in the file LICENSE. | |||
48 | 48 | ||
49 | 49 | ||
50 | /* 90 bytes, 0.3% of overall compress speed */ | 50 | /* 90 bytes, 0.3% of overall compress speed */ |
51 | #if CONFIG_BZIP2_FEATURE_SPEED >= 1 | 51 | #if CONFIG_BZIP2_FAST >= 1 |
52 | 52 | ||
53 | /* macro works better than inline (gcc 4.2.1) */ | 53 | /* macro works better than inline (gcc 4.2.1) */ |
54 | #define DOWNHEAP1(heap, weight, Heap) \ | 54 | #define DOWNHEAP1(heap, weight, Heap) \ |
diff --git a/configs/TEST_nommu_defconfig b/configs/TEST_nommu_defconfig index 905f65296..15e12b1d2 100644 --- a/configs/TEST_nommu_defconfig +++ b/configs/TEST_nommu_defconfig | |||
@@ -79,7 +79,7 @@ CONFIG_PREFIX="./_install" | |||
79 | # Busybox Library Tuning | 79 | # Busybox Library Tuning |
80 | # | 80 | # |
81 | CONFIG_PASSWORD_MINLEN=6 | 81 | CONFIG_PASSWORD_MINLEN=6 |
82 | CONFIG_MD5_SIZE_VS_SPEED=2 | 82 | CONFIG_MD5_SMALL=1 |
83 | CONFIG_FEATURE_FAST_TOP=y | 83 | CONFIG_FEATURE_FAST_TOP=y |
84 | CONFIG_FEATURE_ETC_NETWORKS=y | 84 | CONFIG_FEATURE_ETC_NETWORKS=y |
85 | CONFIG_FEATURE_EDITING=y | 85 | CONFIG_FEATURE_EDITING=y |
diff --git a/configs/TEST_noprintf_defconfig b/configs/TEST_noprintf_defconfig index b72e12856..f4338df71 100644 --- a/configs/TEST_noprintf_defconfig +++ b/configs/TEST_noprintf_defconfig | |||
@@ -89,7 +89,7 @@ CONFIG_PREFIX="./_install" | |||
89 | # Busybox Library Tuning | 89 | # Busybox Library Tuning |
90 | # | 90 | # |
91 | CONFIG_PASSWORD_MINLEN=6 | 91 | CONFIG_PASSWORD_MINLEN=6 |
92 | CONFIG_MD5_SIZE_VS_SPEED=2 | 92 | CONFIG_MD5_SMALL=1 |
93 | CONFIG_FEATURE_FAST_TOP=y | 93 | CONFIG_FEATURE_FAST_TOP=y |
94 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 94 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
95 | CONFIG_FEATURE_EDITING=y | 95 | CONFIG_FEATURE_EDITING=y |
diff --git a/configs/TEST_rh9_defconfig b/configs/TEST_rh9_defconfig index 23094e391..193d8f615 100644 --- a/configs/TEST_rh9_defconfig +++ b/configs/TEST_rh9_defconfig | |||
@@ -88,7 +88,7 @@ CONFIG_PREFIX="./_install" | |||
88 | # Busybox Library Tuning | 88 | # Busybox Library Tuning |
89 | # | 89 | # |
90 | CONFIG_PASSWORD_MINLEN=6 | 90 | CONFIG_PASSWORD_MINLEN=6 |
91 | CONFIG_MD5_SIZE_VS_SPEED=2 | 91 | CONFIG_MD5_SMALL=1 |
92 | CONFIG_FEATURE_FAST_TOP=y | 92 | CONFIG_FEATURE_FAST_TOP=y |
93 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 93 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
94 | CONFIG_FEATURE_EDITING=y | 94 | CONFIG_FEATURE_EDITING=y |
diff --git a/configs/android2_defconfig b/configs/android2_defconfig index 338c7b13d..b5166e0fc 100644 --- a/configs/android2_defconfig +++ b/configs/android2_defconfig | |||
@@ -92,7 +92,7 @@ CONFIG_PREFIX="./_install" | |||
92 | # CONFIG_FEATURE_SYSTEMD is not set | 92 | # CONFIG_FEATURE_SYSTEMD is not set |
93 | # CONFIG_FEATURE_RTMINMAX is not set | 93 | # CONFIG_FEATURE_RTMINMAX is not set |
94 | CONFIG_PASSWORD_MINLEN=6 | 94 | CONFIG_PASSWORD_MINLEN=6 |
95 | CONFIG_MD5_SIZE_VS_SPEED=2 | 95 | CONFIG_MD5_SMALL=1 |
96 | # CONFIG_FEATURE_FAST_TOP is not set | 96 | # CONFIG_FEATURE_FAST_TOP is not set |
97 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 97 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
98 | CONFIG_FEATURE_USE_TERMIOS=y | 98 | CONFIG_FEATURE_USE_TERMIOS=y |
diff --git a/configs/android_defconfig b/configs/android_defconfig index 7e5232a84..76068b040 100644 --- a/configs/android_defconfig +++ b/configs/android_defconfig | |||
@@ -109,7 +109,7 @@ CONFIG_PREFIX="./_install" | |||
109 | # CONFIG_FEATURE_SYSTEMD is not set | 109 | # CONFIG_FEATURE_SYSTEMD is not set |
110 | # CONFIG_FEATURE_RTMINMAX is not set | 110 | # CONFIG_FEATURE_RTMINMAX is not set |
111 | CONFIG_PASSWORD_MINLEN=6 | 111 | CONFIG_PASSWORD_MINLEN=6 |
112 | CONFIG_MD5_SIZE_VS_SPEED=2 | 112 | CONFIG_MD5_SMALL=1 |
113 | # CONFIG_FEATURE_FAST_TOP is not set | 113 | # CONFIG_FEATURE_FAST_TOP is not set |
114 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 114 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
115 | CONFIG_FEATURE_USE_TERMIOS=y | 115 | CONFIG_FEATURE_USE_TERMIOS=y |
diff --git a/configs/cygwin_defconfig b/configs/cygwin_defconfig index cc2d643e1..bdd0d66d0 100644 --- a/configs/cygwin_defconfig +++ b/configs/cygwin_defconfig | |||
@@ -92,7 +92,7 @@ CONFIG_PREFIX="./_install" | |||
92 | # CONFIG_FEATURE_SYSTEMD is not set | 92 | # CONFIG_FEATURE_SYSTEMD is not set |
93 | CONFIG_FEATURE_RTMINMAX=y | 93 | CONFIG_FEATURE_RTMINMAX=y |
94 | CONFIG_PASSWORD_MINLEN=6 | 94 | CONFIG_PASSWORD_MINLEN=6 |
95 | CONFIG_MD5_SIZE_VS_SPEED=2 | 95 | CONFIG_MD5_SMALL=1 |
96 | CONFIG_FEATURE_FAST_TOP=y | 96 | CONFIG_FEATURE_FAST_TOP=y |
97 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 97 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
98 | CONFIG_FEATURE_USE_TERMIOS=y | 98 | CONFIG_FEATURE_USE_TERMIOS=y |
diff --git a/configs/freebsd_defconfig b/configs/freebsd_defconfig index 5f2985be1..dcb5d953c 100644 --- a/configs/freebsd_defconfig +++ b/configs/freebsd_defconfig | |||
@@ -90,7 +90,7 @@ CONFIG_PREFIX="./_install" | |||
90 | # Busybox Library Tuning | 90 | # Busybox Library Tuning |
91 | # | 91 | # |
92 | CONFIG_PASSWORD_MINLEN=6 | 92 | CONFIG_PASSWORD_MINLEN=6 |
93 | CONFIG_MD5_SIZE_VS_SPEED=2 | 93 | CONFIG_MD5_SMALL=1 |
94 | CONFIG_FEATURE_FAST_TOP=y | 94 | CONFIG_FEATURE_FAST_TOP=y |
95 | # CONFIG_FEATURE_ETC_NETWORKS is not set | 95 | # CONFIG_FEATURE_ETC_NETWORKS is not set |
96 | CONFIG_FEATURE_USE_TERMIOS=y | 96 | CONFIG_FEATURE_USE_TERMIOS=y |
diff --git a/libbb/Config.src b/libbb/Config.src index f6f88b9ce..f45e43b04 100644 --- a/libbb/Config.src +++ b/libbb/Config.src | |||
@@ -14,9 +14,9 @@ config PASSWORD_MINLEN | |||
14 | help | 14 | help |
15 | Minimum allowable password length. | 15 | Minimum allowable password length. |
16 | 16 | ||
17 | config MD5_SIZE_VS_SPEED | 17 | config MD5_SMALL |
18 | int "MD5: Trade bytes for speed (0:fast, 3:slow)" | 18 | int "MD5: Trade bytes for speed (0:fast, 3:slow)" |
19 | default 2 | 19 | default 1 |
20 | range 0 3 | 20 | range 0 3 |
21 | help | 21 | help |
22 | Trade binary size versus speed for the md5sum algorithm. | 22 | Trade binary size versus speed for the md5sum algorithm. |
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index b87d1dde8..a313c2a65 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
@@ -104,12 +104,12 @@ static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed) | |||
104 | */ | 104 | */ |
105 | 105 | ||
106 | /* 0: fastest, 3: smallest */ | 106 | /* 0: fastest, 3: smallest */ |
107 | #if CONFIG_MD5_SIZE_VS_SPEED < 0 | 107 | #if CONFIG_MD5_SMALL < 0 |
108 | # define MD5_SIZE_VS_SPEED 0 | 108 | # define MD5_SMALL 0 |
109 | #elif CONFIG_MD5_SIZE_VS_SPEED > 3 | 109 | #elif CONFIG_MD5_SMALL > 3 |
110 | # define MD5_SIZE_VS_SPEED 3 | 110 | # define MD5_SMALL 3 |
111 | #else | 111 | #else |
112 | # define MD5_SIZE_VS_SPEED CONFIG_MD5_SIZE_VS_SPEED | 112 | # define MD5_SMALL CONFIG_MD5_SMALL |
113 | #endif | 113 | #endif |
114 | 114 | ||
115 | /* These are the four functions used in the four steps of the MD5 algorithm | 115 | /* These are the four functions used in the four steps of the MD5 algorithm |
@@ -129,7 +129,7 @@ static void FAST_FUNC common64_end(md5_ctx_t *ctx, int swap_needed) | |||
129 | /* Hash a single block, 64 bytes long and 4-byte aligned */ | 129 | /* Hash a single block, 64 bytes long and 4-byte aligned */ |
130 | static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | 130 | static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) |
131 | { | 131 | { |
132 | #if MD5_SIZE_VS_SPEED > 0 | 132 | #if MD5_SMALL > 0 |
133 | /* Before we start, one word to the strange constants. | 133 | /* Before we start, one word to the strange constants. |
134 | They are defined in RFC 1321 as | 134 | They are defined in RFC 1321 as |
135 | T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64 | 135 | T[i] = (int)(4294967296.0 * fabs(sin(i))), i=1..64 |
@@ -157,7 +157,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
157 | 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 | 157 | 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 |
158 | }; | 158 | }; |
159 | static const char P_array[] ALIGN1 = { | 159 | static const char P_array[] ALIGN1 = { |
160 | # if MD5_SIZE_VS_SPEED > 1 | 160 | # if MD5_SMALL > 1 |
161 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */ | 161 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */ |
162 | # endif | 162 | # endif |
163 | 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */ | 163 | 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */ |
@@ -171,7 +171,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
171 | uint32_t C = ctx->hash[2]; | 171 | uint32_t C = ctx->hash[2]; |
172 | uint32_t D = ctx->hash[3]; | 172 | uint32_t D = ctx->hash[3]; |
173 | 173 | ||
174 | #if MD5_SIZE_VS_SPEED >= 2 /* 2 or 3 */ | 174 | #if MD5_SMALL >= 2 /* 2 or 3 */ |
175 | 175 | ||
176 | static const char S_array[] ALIGN1 = { | 176 | static const char S_array[] ALIGN1 = { |
177 | 7, 12, 17, 22, | 177 | 7, 12, 17, 22, |
@@ -190,7 +190,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
190 | words[i] = SWAP_LE32(words[i]); | 190 | words[i] = SWAP_LE32(words[i]); |
191 | # endif | 191 | # endif |
192 | 192 | ||
193 | # if MD5_SIZE_VS_SPEED == 3 | 193 | # if MD5_SMALL == 3 |
194 | pc = C_array; | 194 | pc = C_array; |
195 | pp = P_array; | 195 | pp = P_array; |
196 | ps = S_array - 4; | 196 | ps = S_array - 4; |
@@ -220,7 +220,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
220 | C = B; | 220 | C = B; |
221 | B = temp; | 221 | B = temp; |
222 | } | 222 | } |
223 | # else /* MD5_SIZE_VS_SPEED == 2 */ | 223 | # else /* MD5_SMALL == 2 */ |
224 | pc = C_array; | 224 | pc = C_array; |
225 | pp = P_array; | 225 | pp = P_array; |
226 | ps = S_array; | 226 | ps = S_array; |
@@ -271,13 +271,13 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
271 | ctx->hash[2] += C; | 271 | ctx->hash[2] += C; |
272 | ctx->hash[3] += D; | 272 | ctx->hash[3] += D; |
273 | 273 | ||
274 | #else /* MD5_SIZE_VS_SPEED == 0 or 1 */ | 274 | #else /* MD5_SMALL == 0 or 1 */ |
275 | 275 | ||
276 | uint32_t A_save = A; | 276 | uint32_t A_save = A; |
277 | uint32_t B_save = B; | 277 | uint32_t B_save = B; |
278 | uint32_t C_save = C; | 278 | uint32_t C_save = C; |
279 | uint32_t D_save = D; | 279 | uint32_t D_save = D; |
280 | # if MD5_SIZE_VS_SPEED == 1 | 280 | # if MD5_SMALL == 1 |
281 | const uint32_t *pc; | 281 | const uint32_t *pc; |
282 | const char *pp; | 282 | const char *pp; |
283 | int i; | 283 | int i; |
@@ -299,7 +299,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
299 | } while (0) | 299 | } while (0) |
300 | 300 | ||
301 | /* Round 1 */ | 301 | /* Round 1 */ |
302 | # if MD5_SIZE_VS_SPEED == 1 | 302 | # if MD5_SMALL == 1 |
303 | pc = C_array; | 303 | pc = C_array; |
304 | for (i = 0; i < 4; i++) { | 304 | for (i = 0; i < 4; i++) { |
305 | OP(A, B, C, D, 7, *pc++); | 305 | OP(A, B, C, D, 7, *pc++); |
@@ -339,7 +339,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
339 | } while (0) | 339 | } while (0) |
340 | 340 | ||
341 | /* Round 2 */ | 341 | /* Round 2 */ |
342 | # if MD5_SIZE_VS_SPEED == 1 | 342 | # if MD5_SMALL == 1 |
343 | pp = P_array; | 343 | pp = P_array; |
344 | for (i = 0; i < 4; i++) { | 344 | for (i = 0; i < 4; i++) { |
345 | OP(FG, A, B, C, D, (int) (*pp++), 5, *pc++); | 345 | OP(FG, A, B, C, D, (int) (*pp++), 5, *pc++); |
@@ -367,7 +367,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
367 | # endif | 367 | # endif |
368 | 368 | ||
369 | /* Round 3 */ | 369 | /* Round 3 */ |
370 | # if MD5_SIZE_VS_SPEED == 1 | 370 | # if MD5_SMALL == 1 |
371 | for (i = 0; i < 4; i++) { | 371 | for (i = 0; i < 4; i++) { |
372 | OP(FH, A, B, C, D, (int) (*pp++), 4, *pc++); | 372 | OP(FH, A, B, C, D, (int) (*pp++), 4, *pc++); |
373 | OP(FH, D, A, B, C, (int) (*pp++), 11, *pc++); | 373 | OP(FH, D, A, B, C, (int) (*pp++), 11, *pc++); |
@@ -394,7 +394,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
394 | # endif | 394 | # endif |
395 | 395 | ||
396 | /* Round 4 */ | 396 | /* Round 4 */ |
397 | # if MD5_SIZE_VS_SPEED == 1 | 397 | # if MD5_SMALL == 1 |
398 | for (i = 0; i < 4; i++) { | 398 | for (i = 0; i < 4; i++) { |
399 | OP(FI, A, B, C, D, (int) (*pp++), 6, *pc++); | 399 | OP(FI, A, B, C, D, (int) (*pp++), 6, *pc++); |
400 | OP(FI, D, A, B, C, (int) (*pp++), 10, *pc++); | 400 | OP(FI, D, A, B, C, (int) (*pp++), 10, *pc++); |
diff --git a/libbb/hash_md5prime.c b/libbb/hash_md5prime.c index 7986f4d29..e089a15f5 100644 --- a/libbb/hash_md5prime.c +++ b/libbb/hash_md5prime.c | |||
@@ -59,7 +59,7 @@ | |||
59 | * Completely removed static PADDING array. | 59 | * Completely removed static PADDING array. |
60 | * | 60 | * |
61 | * Reintroduced the loop unrolling in md5_transform and added the | 61 | * Reintroduced the loop unrolling in md5_transform and added the |
62 | * MD5_SIZE_VS_SPEED option for configurability. Define below as: | 62 | * MD5_SMALL option for configurability. Define below as: |
63 | * 0 fully unrolled loops | 63 | * 0 fully unrolled loops |
64 | * 1 partially unrolled (4 ops per loop) | 64 | * 1 partially unrolled (4 ops per loop) |
65 | * 2 no unrolling -- introduces the need to swap 4 variables (slow) | 65 | * 2 no unrolling -- introduces the need to swap 4 variables (slow) |
@@ -75,12 +75,12 @@ | |||
75 | #include "libbb.h" | 75 | #include "libbb.h" |
76 | 76 | ||
77 | /* 1: fastest, 3: smallest */ | 77 | /* 1: fastest, 3: smallest */ |
78 | #if CONFIG_MD5_SIZE_VS_SPEED < 1 | 78 | #if CONFIG_MD5_SMALL < 1 |
79 | # define MD5_SIZE_VS_SPEED 1 | 79 | # define MD5_SMALL 1 |
80 | #elif CONFIG_MD5_SIZE_VS_SPEED > 3 | 80 | #elif CONFIG_MD5_SMALL > 3 |
81 | # define MD5_SIZE_VS_SPEED 3 | 81 | # define MD5_SMALL 3 |
82 | #else | 82 | #else |
83 | # define MD5_SIZE_VS_SPEED CONFIG_MD5_SIZE_VS_SPEED | 83 | # define MD5_SMALL CONFIG_MD5_SMALL |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #if BB_LITTLE_ENDIAN | 86 | #if BB_LITTLE_ENDIAN |
@@ -152,7 +152,7 @@ memcpy32_le2cpu(uint32_t *output, const unsigned char *input, unsigned len) | |||
152 | static void md5_transform(uint32_t state[4], const unsigned char block[64]) | 152 | static void md5_transform(uint32_t state[4], const unsigned char block[64]) |
153 | { | 153 | { |
154 | uint32_t a, b, c, d, x[16]; | 154 | uint32_t a, b, c, d, x[16]; |
155 | #if MD5_SIZE_VS_SPEED > 1 | 155 | #if MD5_SMALL > 1 |
156 | uint32_t temp; | 156 | uint32_t temp; |
157 | const unsigned char *ps; | 157 | const unsigned char *ps; |
158 | 158 | ||
@@ -162,9 +162,9 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64]) | |||
162 | 4, 11, 16, 23, | 162 | 4, 11, 16, 23, |
163 | 6, 10, 15, 21 | 163 | 6, 10, 15, 21 |
164 | }; | 164 | }; |
165 | #endif /* MD5_SIZE_VS_SPEED > 1 */ | 165 | #endif /* MD5_SMALL > 1 */ |
166 | 166 | ||
167 | #if MD5_SIZE_VS_SPEED > 0 | 167 | #if MD5_SMALL > 0 |
168 | const uint32_t *pc; | 168 | const uint32_t *pc; |
169 | const unsigned char *pp; | 169 | const unsigned char *pp; |
170 | int i; | 170 | int i; |
@@ -198,7 +198,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64]) | |||
198 | 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */ | 198 | 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */ |
199 | }; | 199 | }; |
200 | 200 | ||
201 | #endif /* MD5_SIZE_VS_SPEED > 0 */ | 201 | #endif /* MD5_SMALL > 0 */ |
202 | 202 | ||
203 | memcpy32_le2cpu(x, block, 64); | 203 | memcpy32_le2cpu(x, block, 64); |
204 | 204 | ||
@@ -207,7 +207,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64]) | |||
207 | c = state[2]; | 207 | c = state[2]; |
208 | d = state[3]; | 208 | d = state[3]; |
209 | 209 | ||
210 | #if MD5_SIZE_VS_SPEED > 2 | 210 | #if MD5_SMALL > 2 |
211 | pc = C; | 211 | pc = C; |
212 | pp = P; | 212 | pp = P; |
213 | ps = S - 4; | 213 | ps = S - 4; |
@@ -233,7 +233,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64]) | |||
233 | temp += b; | 233 | temp += b; |
234 | a = d; d = c; c = b; b = temp; | 234 | a = d; d = c; c = b; b = temp; |
235 | } | 235 | } |
236 | #elif MD5_SIZE_VS_SPEED > 1 | 236 | #elif MD5_SMALL > 1 |
237 | pc = C; | 237 | pc = C; |
238 | pp = P; | 238 | pp = P; |
239 | ps = S; | 239 | ps = S; |
@@ -260,7 +260,7 @@ static void md5_transform(uint32_t state[4], const unsigned char block[64]) | |||
260 | II(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++; | 260 | II(a, b, c, d, x[*pp], ps[i & 0x3], *pc); pp++; pc++; |
261 | temp = d; d = c; c = b; b = a; a = temp; | 261 | temp = d; d = c; c = b; b = a; a = temp; |
262 | } | 262 | } |
263 | #elif MD5_SIZE_VS_SPEED > 0 | 263 | #elif MD5_SMALL > 0 |
264 | pc = C; | 264 | pc = C; |
265 | pp = P; | 265 | pp = P; |
266 | /* Round 1 */ | 266 | /* Round 1 */ |