diff options
author | Ron Yorston <rmy@pobox.com> | 2022-01-06 07:46:38 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-01-06 07:46:38 +0000 |
commit | b8751bbc9ac24e71fbe1e79c69074b4c87a134d8 (patch) | |
tree | 336d653df8387b9b1d3c6e46caa373c00cb9b2b2 | |
parent | b15f68214da209b5b293039c09c00f490c0cc193 (diff) | |
parent | 6062c0d19bc201cbeb61b8875598cdd7a14a5ae0 (diff) | |
download | busybox-w32-b8751bbc9ac24e71fbe1e79c69074b4c87a134d8.tar.gz busybox-w32-b8751bbc9ac24e71fbe1e79c69074b4c87a134d8.tar.bz2 busybox-w32-b8751bbc9ac24e71fbe1e79c69074b4c87a134d8.zip |
Merge busybox into merge
Fix merge conflict in miscutils/less.c.
Use exit_SUCCESS() where possible.
60 files changed, 2300 insertions, 152 deletions
diff --git a/coreutils/echo.c b/coreutils/echo.c index 82f0358b6..44b2eb5d0 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -321,6 +321,8 @@ int echo_main(int argc, char **argv) | |||
321 | if (*arg == '0' && (unsigned char)(arg[1] - '0') < 8) { | 321 | if (*arg == '0' && (unsigned char)(arg[1] - '0') < 8) { |
322 | arg++; | 322 | arg++; |
323 | } | 323 | } |
324 | //FIXME? we also accept non-0 starting sequences (see echo-prints-slash_41 test) | ||
325 | // echo -ne '-\41-' prints "-!-". bash 5.0.17 does not (prints "-\41-"). | ||
324 | /* bb_process_escape_sequence can handle nul correctly */ | 326 | /* bb_process_escape_sequence can handle nul correctly */ |
325 | c = bb_process_escape_sequence( (void*) &arg); | 327 | c = bb_process_escape_sequence( (void*) &arg); |
326 | } | 328 | } |
diff --git a/coreutils/env.c b/coreutils/env.c index a0ea4dd27..6eafd06ef 100644 --- a/coreutils/env.c +++ b/coreutils/env.c | |||
@@ -100,7 +100,7 @@ int env_main(int argc UNUSED_PARAM, char **argv) | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | fflush_stdout_and_exit(EXIT_SUCCESS); | 103 | fflush_stdout_and_exit_SUCCESS(); |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 4efa23061..3b389cb6b 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
@@ -151,10 +151,12 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value, | |||
151 | return (unsigned char *)hex_value; | 151 | return (unsigned char *)hex_value; |
152 | } | 152 | } |
153 | 153 | ||
154 | #define BUFSZ (CONFIG_FEATURE_COPYBUF_KB < 4 ? 4096 : CONFIG_FEATURE_COPYBUF_KB * 1024) | ||
155 | |||
154 | #if !ENABLE_SHA3SUM | 156 | #if !ENABLE_SHA3SUM |
155 | # define hash_file(f,w) hash_file(f) | 157 | # define hash_file(b,f,w) hash_file(b,f) |
156 | #endif | 158 | #endif |
157 | static uint8_t *hash_file(const char *filename, unsigned sha3_width) | 159 | static uint8_t *hash_file(unsigned char *in_buf, const char *filename, unsigned sha3_width) |
158 | { | 160 | { |
159 | int src_fd, hash_len, count; | 161 | int src_fd, hash_len, count; |
160 | union _ctx_ { | 162 | union _ctx_ { |
@@ -227,8 +229,7 @@ static uint8_t *hash_file(const char *filename, unsigned sha3_width) | |||
227 | } | 229 | } |
228 | 230 | ||
229 | { | 231 | { |
230 | RESERVE_CONFIG_UBUFFER(in_buf, 4096); | 232 | while ((count = safe_read(src_fd, in_buf, BUFSZ)) > 0) { |
231 | while ((count = safe_read(src_fd, in_buf, 4096)) > 0) { | ||
232 | update(&context, in_buf, count); | 233 | update(&context, in_buf, count); |
233 | } | 234 | } |
234 | hash_value = NULL; | 235 | hash_value = NULL; |
@@ -238,7 +239,6 @@ static uint8_t *hash_file(const char *filename, unsigned sha3_width) | |||
238 | final(&context, in_buf); | 239 | final(&context, in_buf); |
239 | hash_value = hash_bin_to_hex(in_buf, hash_len); | 240 | hash_value = hash_bin_to_hex(in_buf, hash_len); |
240 | } | 241 | } |
241 | RELEASE_CONFIG_BUFFER(in_buf); | ||
242 | } | 242 | } |
243 | 243 | ||
244 | if (src_fd != STDIN_FILENO) { | 244 | if (src_fd != STDIN_FILENO) { |
@@ -251,6 +251,7 @@ static uint8_t *hash_file(const char *filename, unsigned sha3_width) | |||
251 | int md5_sha1_sum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 251 | int md5_sha1_sum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
252 | int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | 252 | int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) |
253 | { | 253 | { |
254 | unsigned char *in_buf; | ||
254 | int return_value = EXIT_SUCCESS; | 255 | int return_value = EXIT_SUCCESS; |
255 | unsigned flags; | 256 | unsigned flags; |
256 | #if ENABLE_SHA3SUM | 257 | #if ENABLE_SHA3SUM |
@@ -279,6 +280,12 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | |||
279 | if (!*argv) | 280 | if (!*argv) |
280 | *--argv = (char*)"-"; | 281 | *--argv = (char*)"-"; |
281 | 282 | ||
283 | /* The buffer is not alloc/freed for each input file: | ||
284 | * for big values of COPYBUF_KB, this helps to keep its pages | ||
285 | * pre-faulted and possibly even fully cached on local CPU. | ||
286 | */ | ||
287 | in_buf = xmalloc(BUFSZ); | ||
288 | |||
282 | do { | 289 | do { |
283 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && (flags & FLAG_CHECK)) { | 290 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && (flags & FLAG_CHECK)) { |
284 | FILE *pre_computed_stream; | 291 | FILE *pre_computed_stream; |
@@ -310,7 +317,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | |||
310 | *filename_ptr = '\0'; | 317 | *filename_ptr = '\0'; |
311 | filename_ptr += 2; | 318 | filename_ptr += 2; |
312 | 319 | ||
313 | hash_value = hash_file(filename_ptr, sha3_width); | 320 | hash_value = hash_file(in_buf, filename_ptr, sha3_width); |
314 | 321 | ||
315 | if (hash_value && (strcmp((char*)hash_value, line) == 0)) { | 322 | if (hash_value && (strcmp((char*)hash_value, line) == 0)) { |
316 | if (!(flags & FLAG_SILENT)) | 323 | if (!(flags & FLAG_SILENT)) |
@@ -339,7 +346,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv) | |||
339 | } | 346 | } |
340 | fclose_if_not_stdin(pre_computed_stream); | 347 | fclose_if_not_stdin(pre_computed_stream); |
341 | } else { | 348 | } else { |
342 | uint8_t *hash_value = hash_file(*argv, sha3_width); | 349 | uint8_t *hash_value = hash_file(in_buf, *argv, sha3_width); |
343 | if (hash_value == NULL) { | 350 | if (hash_value == NULL) { |
344 | return_value = EXIT_FAILURE; | 351 | return_value = EXIT_FAILURE; |
345 | } else { | 352 | } else { |
diff --git a/coreutils/nice.c b/coreutils/nice.c index 28591ac61..e70da5d2b 100644 --- a/coreutils/nice.c +++ b/coreutils/nice.c | |||
@@ -33,7 +33,7 @@ int nice_main(int argc UNUSED_PARAM, char **argv) | |||
33 | 33 | ||
34 | if (!*++argv) { /* No args, so (GNU) output current nice value. */ | 34 | if (!*++argv) { /* No args, so (GNU) output current nice value. */ |
35 | printf("%d\n", old_priority); | 35 | printf("%d\n", old_priority); |
36 | fflush_stdout_and_exit(EXIT_SUCCESS); | 36 | fflush_stdout_and_exit_SUCCESS(); |
37 | } | 37 | } |
38 | 38 | ||
39 | adjustment = 10; /* Set default adjustment. */ | 39 | adjustment = 10; /* Set default adjustment. */ |
diff --git a/coreutils/readlink.c b/coreutils/readlink.c index 09d69df2b..b2e867883 100644 --- a/coreutils/readlink.c +++ b/coreutils/readlink.c | |||
@@ -96,5 +96,5 @@ int readlink_main(int argc UNUSED_PARAM, char **argv) | |||
96 | printf((opt & 2) ? "%s" : "%s\n", buf); | 96 | printf((opt & 2) ? "%s" : "%s\n", buf); |
97 | free(buf); | 97 | free(buf); |
98 | 98 | ||
99 | fflush_stdout_and_exit(EXIT_SUCCESS); | 99 | fflush_stdout_and_exit_SUCCESS(); |
100 | } | 100 | } |
diff --git a/coreutils/shuf.c b/coreutils/shuf.c index 81b0df453..56ba03aad 100644 --- a/coreutils/shuf.c +++ b/coreutils/shuf.c | |||
@@ -171,5 +171,5 @@ int shuf_main(int argc, char **argv) | |||
171 | printf("%s%c", lines[i], eol); | 171 | printf("%s%c", lines[i], eol); |
172 | } | 172 | } |
173 | 173 | ||
174 | fflush_stdout_and_exit(EXIT_SUCCESS); | 174 | fflush_stdout_and_exit_SUCCESS(); |
175 | } | 175 | } |
diff --git a/coreutils/sort.c b/coreutils/sort.c index 32a06e40a..9aac656fe 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
@@ -18,7 +18,7 @@ | |||
18 | //config: sort is used to sort lines of text in specified files. | 18 | //config: sort is used to sort lines of text in specified files. |
19 | //config: | 19 | //config: |
20 | //config:config FEATURE_SORT_BIG | 20 | //config:config FEATURE_SORT_BIG |
21 | //config: bool "Full SuSv3 compliant sort (support -ktcbdfiogM)" | 21 | //config: bool "Full SuSv3 compliant sort (support -ktcbdfioghM)" |
22 | //config: default y | 22 | //config: default y |
23 | //config: depends on SORT | 23 | //config: depends on SORT |
24 | //config: help | 24 | //config: help |
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | //usage:#define sort_trivial_usage | 44 | //usage:#define sort_trivial_usage |
45 | //usage: "[-nru" | 45 | //usage: "[-nru" |
46 | //usage: IF_FEATURE_SORT_BIG("gMcszbdfiokt] [-o FILE] [-k START[.OFS][OPTS][,END[.OFS][OPTS]] [-t CHAR") | 46 | //usage: IF_FEATURE_SORT_BIG("ghMcszbdfiokt] [-o FILE] [-k START[.OFS][OPTS][,END[.OFS][OPTS]] [-t CHAR") |
47 | //usage: "] [FILE]..." | 47 | //usage: "] [FILE]..." |
48 | //usage:#define sort_full_usage "\n\n" | 48 | //usage:#define sort_full_usage "\n\n" |
49 | //usage: "Sort lines of text\n" | 49 | //usage: "Sort lines of text\n" |
@@ -59,6 +59,7 @@ | |||
59 | //usage: "\n -n Sort numbers" | 59 | //usage: "\n -n Sort numbers" |
60 | //usage: IF_FEATURE_SORT_BIG( | 60 | //usage: IF_FEATURE_SORT_BIG( |
61 | //usage: "\n -g General numerical sort" | 61 | //usage: "\n -g General numerical sort" |
62 | //usage: "\n -h Sort human readable numbers (2K 1G)" | ||
62 | //usage: "\n -M Sort month" | 63 | //usage: "\n -M Sort month" |
63 | //usage: "\n -V Sort version" | 64 | //usage: "\n -V Sort version" |
64 | //usage: "\n -t CHAR Field separator" | 65 | //usage: "\n -t CHAR Field separator" |
@@ -94,31 +95,32 @@ | |||
94 | enum { | 95 | enum { |
95 | FLAG_n = 1 << 0, /* Numeric sort */ | 96 | FLAG_n = 1 << 0, /* Numeric sort */ |
96 | FLAG_g = 1 << 1, /* Sort using strtod() */ | 97 | FLAG_g = 1 << 1, /* Sort using strtod() */ |
97 | FLAG_M = 1 << 2, /* Sort date */ | 98 | FLAG_h = 1 << 2, /* Sort using strtod(), plus KMGT suffixes */ |
98 | FLAG_V = 1 << 3, /* Sort version */ | 99 | FLAG_M = 1 << 3, /* Sort date */ |
100 | FLAG_V = 1 << 4, /* Sort version */ | ||
99 | /* ucsz apply to root level only, not keys. b at root level implies bb */ | 101 | /* ucsz apply to root level only, not keys. b at root level implies bb */ |
100 | FLAG_u = 1 << 4, /* Unique */ | 102 | FLAG_u = 1 << 5, /* Unique */ |
101 | FLAG_c = 1 << 5, /* Check: no output, exit(!ordered) */ | 103 | FLAG_c = 1 << 6, /* Check: no output, exit(!ordered) */ |
102 | FLAG_s = 1 << 6, /* Stable sort, no ascii fallback at end */ | 104 | FLAG_s = 1 << 7, /* Stable sort, no ascii fallback at end */ |
103 | FLAG_z = 1 << 7, /* Input and output is NUL terminated, not \n */ | 105 | FLAG_z = 1 << 8, /* Input and output is NUL terminated, not \n */ |
104 | /* These can be applied to search keys, the previous four can't */ | 106 | /* These can be applied to search keys, the previous four can't */ |
105 | FLAG_b = 1 << 8, /* Ignore leading blanks */ | 107 | FLAG_b = 1 << 9, /* Ignore leading blanks */ |
106 | FLAG_r = 1 << 9, /* Reverse */ | 108 | FLAG_r = 1 << 10, /* Reverse */ |
107 | FLAG_d = 1 << 10, /* Ignore !(isalnum()|isspace()) */ | 109 | FLAG_d = 1 << 11, /* Ignore !(isalnum()|isspace()) */ |
108 | FLAG_f = 1 << 11, /* Force uppercase */ | 110 | FLAG_f = 1 << 12, /* Force uppercase */ |
109 | FLAG_i = 1 << 12, /* Ignore !isprint() */ | 111 | FLAG_i = 1 << 13, /* Ignore !isprint() */ |
110 | FLAG_m = 1 << 13, /* ignored: merge already sorted files; do not sort */ | 112 | FLAG_m = 1 << 14, /* ignored: merge already sorted files; do not sort */ |
111 | FLAG_S = 1 << 14, /* ignored: -S, --buffer-size=SIZE */ | 113 | FLAG_S = 1 << 15, /* ignored: -S, --buffer-size=SIZE */ |
112 | FLAG_T = 1 << 15, /* ignored: -T, --temporary-directory=DIR */ | 114 | FLAG_T = 1 << 16, /* ignored: -T, --temporary-directory=DIR */ |
113 | FLAG_o = 1 << 16, | 115 | FLAG_o = 1 << 17, |
114 | FLAG_k = 1 << 17, | 116 | FLAG_k = 1 << 18, |
115 | FLAG_t = 1 << 18, | 117 | FLAG_t = 1 << 19, |
116 | FLAG_bb = 0x80000000, /* Ignore trailing blanks */ | 118 | FLAG_bb = 0x80000000, /* Ignore trailing blanks */ |
117 | FLAG_no_tie_break = 0x40000000, | 119 | FLAG_no_tie_break = 0x40000000, |
118 | }; | 120 | }; |
119 | 121 | ||
120 | static const char sort_opt_str[] ALIGN1 = "^" | 122 | static const char sort_opt_str[] ALIGN1 = "^" |
121 | "ngMVucszbrdfimS:T:o:k:*t:" | 123 | "nghMVucszbrdfimS:T:o:k:*t:" |
122 | "\0" "o--o:t--t"/*-t, -o: at most one of each*/; | 124 | "\0" "o--o:t--t"/*-t, -o: at most one of each*/; |
123 | /* | 125 | /* |
124 | * OPT_STR must not be string literal, needs to have stable address: | 126 | * OPT_STR must not be string literal, needs to have stable address: |
@@ -253,6 +255,25 @@ static struct sort_key *add_key(void) | |||
253 | #define GET_LINE(fp) xmalloc_fgetline(fp) | 255 | #define GET_LINE(fp) xmalloc_fgetline(fp) |
254 | #endif | 256 | #endif |
255 | 257 | ||
258 | #if ENABLE_FEATURE_SORT_BIG | ||
259 | static int scale_suffix(const char *tail) | ||
260 | { | ||
261 | static const char suffix[] ALIGN1 = "kmgtpezy"; | ||
262 | const char *s; | ||
263 | int n; | ||
264 | |||
265 | if (!tail[0]) | ||
266 | return -1; | ||
267 | s = strchr(suffix, tail[0] | 0x20); | ||
268 | if (!s) | ||
269 | return -1; | ||
270 | n = s - suffix; | ||
271 | if (n != 0 && tail[0] >= 'a') | ||
272 | return -1; /* mg... not accepted, only MG... */ | ||
273 | return n; | ||
274 | } | ||
275 | #endif | ||
276 | |||
256 | /* Iterate through keys list and perform comparisons */ | 277 | /* Iterate through keys list and perform comparisons */ |
257 | static int compare_keys(const void *xarg, const void *yarg) | 278 | static int compare_keys(const void *xarg, const void *yarg) |
258 | { | 279 | { |
@@ -275,7 +296,7 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
275 | y = *(char **)yarg; | 296 | y = *(char **)yarg; |
276 | #endif | 297 | #endif |
277 | /* Perform actual comparison */ | 298 | /* Perform actual comparison */ |
278 | switch (flags & (FLAG_n | FLAG_g | FLAG_M | FLAG_V)) { | 299 | switch (flags & (FLAG_n | FLAG_g | FLAG_h | FLAG_M | FLAG_V)) { |
279 | default: | 300 | default: |
280 | bb_simple_error_msg_and_die("unknown sort type"); | 301 | bb_simple_error_msg_and_die("unknown sort type"); |
281 | break; | 302 | break; |
@@ -293,7 +314,8 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
293 | #endif | 314 | #endif |
294 | break; | 315 | break; |
295 | #if ENABLE_FEATURE_SORT_BIG | 316 | #if ENABLE_FEATURE_SORT_BIG |
296 | case FLAG_g: { | 317 | case FLAG_g: |
318 | case FLAG_h: { | ||
297 | char *xx, *yy; | 319 | char *xx, *yy; |
298 | //TODO: needs setlocale(LC_NUMERIC, "C")? | 320 | //TODO: needs setlocale(LC_NUMERIC, "C")? |
299 | double dx = strtod(x, &xx); | 321 | double dx = strtod(x, &xx); |
@@ -308,16 +330,26 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
308 | retval = (dy != dy) ? 0 : -1; | 330 | retval = (dy != dy) ? 0 : -1; |
309 | else if (dy != dy) | 331 | else if (dy != dy) |
310 | retval = 1; | 332 | retval = 1; |
311 | /* Check for infinity. Could underflow, but it avoids libm. */ | 333 | else { |
312 | else if (1.0 / dx == 0.0) { | 334 | if (flags & FLAG_h) { |
313 | if (dx < 0) | 335 | int xs = scale_suffix(xx); |
314 | retval = (1.0 / dy == 0.0 && dy < 0) ? 0 : -1; | 336 | int ys = scale_suffix(yy); |
337 | if (xs != ys) { | ||
338 | retval = xs - ys; | ||
339 | break; | ||
340 | } | ||
341 | } | ||
342 | /* Check for infinity. Could underflow, but it avoids libm. */ | ||
343 | if (1.0 / dx == 0.0) { | ||
344 | if (dx < 0) | ||
345 | retval = (1.0 / dy == 0.0 && dy < 0) ? 0 : -1; | ||
346 | else | ||
347 | retval = (1.0 / dy == 0.0 && dy > 0) ? 0 : 1; | ||
348 | } else if (1.0 / dy == 0.0) | ||
349 | retval = (dy < 0) ? 1 : -1; | ||
315 | else | 350 | else |
316 | retval = (1.0 / dy == 0.0 && dy > 0) ? 0 : 1; | 351 | retval = (dx > dy) ? 1 : ((dx < dy) ? -1 : 0); |
317 | } else if (1.0 / dy == 0.0) | 352 | } |
318 | retval = (dy < 0) ? 1 : -1; | ||
319 | else | ||
320 | retval = (dx > dy) ? 1 : ((dx < dy) ? -1 : 0); | ||
321 | break; | 353 | break; |
322 | } | 354 | } |
323 | case FLAG_M: { | 355 | case FLAG_M: { |
@@ -380,7 +412,9 @@ static int compare_keys(const void *xarg, const void *yarg) | |||
380 | 412 | ||
381 | /* If x > y, 1, else -1 */ | 413 | /* If x > y, 1, else -1 */ |
382 | retval = (x32 > y32) * 2 - 1; | 414 | retval = (x32 > y32) * 2 - 1; |
383 | } else | 415 | /* Here, -r has no effect! */ |
416 | return retval; | ||
417 | } | ||
384 | if (!(option_mask32 & FLAG_no_tie_break)) { | 418 | if (!(option_mask32 & FLAG_no_tie_break)) { |
385 | /* fallback sort */ | 419 | /* fallback sort */ |
386 | flags = option_mask32; | 420 | flags = option_mask32; |
@@ -474,6 +508,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv) | |||
474 | FLAG_allowed_for_k = | 508 | FLAG_allowed_for_k = |
475 | FLAG_n | /* Numeric sort */ | 509 | FLAG_n | /* Numeric sort */ |
476 | FLAG_g | /* Sort using strtod() */ | 510 | FLAG_g | /* Sort using strtod() */ |
511 | FLAG_h | /* Sort using strtod(), plus KMGT suffixes */ | ||
477 | FLAG_M | /* Sort date */ | 512 | FLAG_M | /* Sort date */ |
478 | FLAG_b | /* Ignore leading blanks */ | 513 | FLAG_b | /* Ignore leading blanks */ |
479 | FLAG_r | /* Reverse */ | 514 | FLAG_r | /* Reverse */ |
@@ -644,5 +679,5 @@ int sort_main(int argc UNUSED_PARAM, char **argv) | |||
644 | printf("%s%c", lines[i], ch); | 679 | printf("%s%c", lines[i], ch); |
645 | } | 680 | } |
646 | 681 | ||
647 | fflush_stdout_and_exit(EXIT_SUCCESS); | 682 | fflush_stdout_and_exit_SUCCESS(); |
648 | } | 683 | } |
diff --git a/coreutils/uname.c b/coreutils/uname.c index da785ab4c..6c0bdf096 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c | |||
@@ -209,5 +209,5 @@ int uname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */ | 212 | fflush_stdout_and_exit_SUCCESS(); /* coreutils-6.9 compat */ |
213 | } | 213 | } |
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index a3058ac07..06c57f750 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -139,5 +139,5 @@ int uniq_main(int argc UNUSED_PARAM, char **argv) | |||
139 | 139 | ||
140 | die_if_ferror(stdin, input_filename); | 140 | die_if_ferror(stdin, input_filename); |
141 | 141 | ||
142 | fflush_stdout_and_exit(EXIT_SUCCESS); | 142 | fflush_stdout_and_exit_SUCCESS(); |
143 | } | 143 | } |
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index e90902f52..63a8d4d48 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -352,7 +352,7 @@ int baseNUM_main(int argc UNUSED_PARAM, char **argv) | |||
352 | #undef src_buf | 352 | #undef src_buf |
353 | } | 353 | } |
354 | 354 | ||
355 | fflush_stdout_and_exit(EXIT_SUCCESS); | 355 | fflush_stdout_and_exit_SUCCESS(); |
356 | } | 356 | } |
357 | #endif | 357 | #endif |
358 | 358 | ||
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index db49ec80a..f096e3122 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c | |||
@@ -78,5 +78,5 @@ int uuencode_main(int argc UNUSED_PARAM, char **argv) | |||
78 | } | 78 | } |
79 | printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); | 79 | printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); |
80 | 80 | ||
81 | fflush_stdout_and_exit(EXIT_SUCCESS); | 81 | fflush_stdout_and_exit_SUCCESS(); |
82 | } | 82 | } |
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 68df44ae9..3e5dd9faa 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
@@ -519,7 +519,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) | |||
519 | /* why _exit? the child may have changed the stack, | 519 | /* why _exit? the child may have changed the stack, |
520 | * so "return 0" may do bad things | 520 | * so "return 0" may do bad things |
521 | */ | 521 | */ |
522 | _exit(EXIT_SUCCESS); | 522 | _exit_SUCCESS(); |
523 | } | 523 | } |
524 | /* Child */ | 524 | /* Child */ |
525 | setsid(); /* detach from controlling tty */ | 525 | setsid(); /* detach from controlling tty */ |
@@ -531,7 +531,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv) | |||
531 | */ | 531 | */ |
532 | pid = xvfork(); | 532 | pid = xvfork(); |
533 | if (pid != 0) | 533 | if (pid != 0) |
534 | _exit(EXIT_SUCCESS); /* Parent */ | 534 | _exit_SUCCESS(); /* Parent */ |
535 | } | 535 | } |
536 | if (opt & OPT_MAKEPID) { | 536 | if (opt & OPT_MAKEPID) { |
537 | /* User wants _us_ to make the pidfile */ | 537 | /* User wants _us_ to make the pidfile */ |
diff --git a/editors/ed.c b/editors/ed.c index dfe0f1a77..209ce9942 100644 --- a/editors/ed.c +++ b/editors/ed.c | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | //applet:IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) | 19 | //applet:IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) |
20 | 20 | ||
21 | //usage:#define ed_trivial_usage "[-p PROMPT] [FILE]" | 21 | //usage:#define ed_trivial_usage "[-p PROMPT] [-s] [FILE]" |
22 | //usage:#define ed_full_usage "" | 22 | //usage:#define ed_full_usage "" |
23 | 23 | ||
24 | #include "libbb.h" | 24 | #include "libbb.h" |
@@ -71,6 +71,11 @@ struct globals { | |||
71 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 71 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
72 | } while (0) | 72 | } while (0) |
73 | 73 | ||
74 | #define OPTION_STR "sp:" | ||
75 | enum { | ||
76 | OPT_s = (1 << 0), | ||
77 | }; | ||
78 | |||
74 | static int bad_nums(int num1, int num2, const char *for_what) | 79 | static int bad_nums(int num1, int num2, const char *for_what) |
75 | { | 80 | { |
76 | if ((num1 < 1) || (num2 > lastNum) || (num1 > num2)) { | 81 | if ((num1 < 1) || (num2 > lastNum) || (num1 > num2)) { |
@@ -458,7 +463,8 @@ static int readLines(const char *file, int num) | |||
458 | * in the following format: | 463 | * in the following format: |
459 | * "%d\n", <number of bytes read> | 464 | * "%d\n", <number of bytes read> |
460 | */ | 465 | */ |
461 | printf("%u\n", charCount); | 466 | if (!(option_mask32 & OPT_s)) |
467 | printf("%u\n", charCount); | ||
462 | return TRUE; | 468 | return TRUE; |
463 | } | 469 | } |
464 | 470 | ||
@@ -510,7 +516,8 @@ static int writeLines(const char *file, int num1, int num2) | |||
510 | * unless the -s option was specified, in the following format: | 516 | * unless the -s option was specified, in the following format: |
511 | * "%d\n", <number of bytes written> | 517 | * "%d\n", <number of bytes written> |
512 | */ | 518 | */ |
513 | printf("%u\n", charCount); | 519 | if (!(option_mask32 & OPT_s)) |
520 | printf("%u\n", charCount); | ||
514 | return TRUE; | 521 | return TRUE; |
515 | } | 522 | } |
516 | 523 | ||
@@ -1005,7 +1012,7 @@ int ed_main(int argc UNUSED_PARAM, char **argv) | |||
1005 | lines.prev = &lines; | 1012 | lines.prev = &lines; |
1006 | 1013 | ||
1007 | prompt = ""; /* no prompt by default */ | 1014 | prompt = ""; /* no prompt by default */ |
1008 | getopt32(argv, "p:", &prompt); | 1015 | getopt32(argv, OPTION_STR, &prompt); |
1009 | argv += optind; | 1016 | argv += optind; |
1010 | 1017 | ||
1011 | if (argv[0]) { | 1018 | if (argv[0]) { |
diff --git a/editors/sed.c b/editors/sed.c index 73034438a..374830f3f 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -100,6 +100,12 @@ enum { | |||
100 | OPT_in_place = 1 << 0, | 100 | OPT_in_place = 1 << 0, |
101 | }; | 101 | }; |
102 | 102 | ||
103 | struct sed_FILE { | ||
104 | struct sed_FILE *next; /* Next (linked list, NULL terminated) */ | ||
105 | const char *fname; | ||
106 | FILE *fp; | ||
107 | }; | ||
108 | |||
103 | /* Each sed command turns into one of these structures. */ | 109 | /* Each sed command turns into one of these structures. */ |
104 | typedef struct sed_cmd_s { | 110 | typedef struct sed_cmd_s { |
105 | /* Ordered by alignment requirements: currently 36 bytes on x86 */ | 111 | /* Ordered by alignment requirements: currently 36 bytes on x86 */ |
@@ -157,6 +163,11 @@ struct globals { | |||
157 | /* linked list of append lines */ | 163 | /* linked list of append lines */ |
158 | llist_t *append_head; | 164 | llist_t *append_head; |
159 | 165 | ||
166 | /* linked list of FILEs opened for 'w' and s///w'. | ||
167 | * Needed to handle duplicate fnames: sed '/a/w F;/b/w F' | ||
168 | */ | ||
169 | struct sed_FILE *FILE_head; | ||
170 | |||
160 | char *add_cmd_line; | 171 | char *add_cmd_line; |
161 | 172 | ||
162 | struct pipeline { | 173 | struct pipeline { |
@@ -217,6 +228,22 @@ static void sed_free_and_close_stuff(void) | |||
217 | void sed_free_and_close_stuff(void); | 228 | void sed_free_and_close_stuff(void); |
218 | #endif | 229 | #endif |
219 | 230 | ||
231 | static FILE *sed_xfopen_w(const char *fname) | ||
232 | { | ||
233 | struct sed_FILE **pp = &G.FILE_head; | ||
234 | struct sed_FILE *cur; | ||
235 | while ((cur = *pp) != NULL) { | ||
236 | if (strcmp(cur->fname, fname) == 0) | ||
237 | return cur->fp; | ||
238 | pp = &cur->next; | ||
239 | } | ||
240 | *pp = cur = xzalloc(sizeof(*cur)); | ||
241 | /*cur->next = NULL; - already is */ | ||
242 | cur->fname = xstrdup(fname); | ||
243 | cur->fp = xfopen_for_write(fname); | ||
244 | return cur->fp; | ||
245 | } | ||
246 | |||
220 | /* If something bad happens during -i operation, delete temp file */ | 247 | /* If something bad happens during -i operation, delete temp file */ |
221 | 248 | ||
222 | static void cleanup_outname(void) | 249 | static void cleanup_outname(void) |
@@ -452,7 +479,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) | |||
452 | { | 479 | { |
453 | char *fname; | 480 | char *fname; |
454 | idx += parse_file_cmd(/*sed_cmd,*/ substr+idx+1, &fname); | 481 | idx += parse_file_cmd(/*sed_cmd,*/ substr+idx+1, &fname); |
455 | sed_cmd->sw_file = xfopen_for_write(fname); | 482 | sed_cmd->sw_file = sed_xfopen_w(fname); |
456 | sed_cmd->sw_last_char = '\n'; | 483 | sed_cmd->sw_last_char = '\n'; |
457 | free(fname); | 484 | free(fname); |
458 | break; | 485 | break; |
@@ -567,7 +594,7 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr) | |||
567 | } | 594 | } |
568 | cmdstr += parse_file_cmd(/*sed_cmd,*/ cmdstr, &sed_cmd->string); | 595 | cmdstr += parse_file_cmd(/*sed_cmd,*/ cmdstr, &sed_cmd->string); |
569 | if (sed_cmd->cmd == 'w') { | 596 | if (sed_cmd->cmd == 'w') { |
570 | sed_cmd->sw_file = xfopen_for_write(sed_cmd->string); | 597 | sed_cmd->sw_file = sed_xfopen_w(sed_cmd->string); |
571 | sed_cmd->sw_last_char = '\n'; | 598 | sed_cmd->sw_last_char = '\n'; |
572 | } | 599 | } |
573 | } | 600 | } |
diff --git a/findutils/grep.c b/findutils/grep.c index 8600d72fa..0b72812f1 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -470,7 +470,7 @@ static int grep_file(FILE *file) | |||
470 | * "exit immediately with zero status | 470 | * "exit immediately with zero status |
471 | * if any match is found, | 471 | * if any match is found, |
472 | * even if errors were detected" */ | 472 | * even if errors were detected" */ |
473 | exit(EXIT_SUCCESS); | 473 | exit_SUCCESS(); |
474 | } | 474 | } |
475 | /* -l "print filenames with matches": stop after the first match */ | 475 | /* -l "print filenames with matches": stop after the first match */ |
476 | if (option_mask32 & OPT_l) { | 476 | if (option_mask32 & OPT_l) { |
diff --git a/include/libbb.h b/include/libbb.h index 9aff42e67..e332f165a 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -454,8 +454,8 @@ void *xrealloc(void *old, size_t size) FAST_FUNC; | |||
454 | xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) | 454 | xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx)) |
455 | void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; | 455 | void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC; |
456 | char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; | 456 | char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC; |
457 | char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC; | 457 | char *xstrndup(const char *s, size_t n) FAST_FUNC RETURNS_MALLOC; |
458 | void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC; | 458 | void *xmemdup(const void *s, size_t n) FAST_FUNC RETURNS_MALLOC; |
459 | void *mmap_read(int fd, size_t size) FAST_FUNC; | 459 | void *mmap_read(int fd, size_t size) FAST_FUNC; |
460 | void *mmap_anon(size_t size) FAST_FUNC; | 460 | void *mmap_anon(size_t size) FAST_FUNC; |
461 | void *xmmap_anon(size_t size) FAST_FUNC; | 461 | void *xmmap_anon(size_t size) FAST_FUNC; |
@@ -1100,6 +1100,7 @@ void die_if_ferror(FILE *file, const char *msg) FAST_FUNC; | |||
1100 | void die_if_ferror_stdout(void) FAST_FUNC; | 1100 | void die_if_ferror_stdout(void) FAST_FUNC; |
1101 | int fflush_all(void) FAST_FUNC; | 1101 | int fflush_all(void) FAST_FUNC; |
1102 | void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC; | 1102 | void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC; |
1103 | void fflush_stdout_and_exit_SUCCESS(void) NORETURN FAST_FUNC; | ||
1103 | int fclose_if_not_stdin(FILE *file) FAST_FUNC; | 1104 | int fclose_if_not_stdin(FILE *file) FAST_FUNC; |
1104 | FILE* xfopen(const char *filename, const char *mode) FAST_FUNC; | 1105 | FILE* xfopen(const char *filename, const char *mode) FAST_FUNC; |
1105 | /* Prints warning to stderr and returns NULL on failure: */ | 1106 | /* Prints warning to stderr and returns NULL on failure: */ |
@@ -1327,6 +1328,8 @@ void set_task_comm(const char *comm) FAST_FUNC; | |||
1327 | # define re_execed_comm() 0 | 1328 | # define re_execed_comm() 0 |
1328 | # define set_task_comm(name) ((void)0) | 1329 | # define set_task_comm(name) ((void)0) |
1329 | #endif | 1330 | #endif |
1331 | void exit_SUCCESS(void) NORETURN FAST_FUNC; | ||
1332 | void _exit_SUCCESS(void) NORETURN FAST_FUNC; | ||
1330 | 1333 | ||
1331 | /* Helpers for daemonization. | 1334 | /* Helpers for daemonization. |
1332 | * | 1335 | * |
diff --git a/init/init.c b/init/init.c index efab5dcb4..785a3b460 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -744,7 +744,7 @@ static void pause_and_low_level_reboot(unsigned magic) | |||
744 | pid = vfork(); | 744 | pid = vfork(); |
745 | if (pid == 0) { /* child */ | 745 | if (pid == 0) { /* child */ |
746 | reboot(magic); | 746 | reboot(magic); |
747 | _exit(EXIT_SUCCESS); | 747 | _exit_SUCCESS(); |
748 | } | 748 | } |
749 | /* Used to have "while (1) sleep(1)" here. | 749 | /* Used to have "while (1) sleep(1)" here. |
750 | * However, in containers reboot() call is ignored, and with that loop | 750 | * However, in containers reboot() call is ignored, and with that loop |
@@ -752,7 +752,7 @@ static void pause_and_low_level_reboot(unsigned magic) | |||
752 | */ | 752 | */ |
753 | waitpid(pid, NULL, 0); | 753 | waitpid(pid, NULL, 0); |
754 | sleep1(); /* paranoia */ | 754 | sleep1(); /* paranoia */ |
755 | _exit(EXIT_SUCCESS); | 755 | _exit_SUCCESS(); |
756 | } | 756 | } |
757 | 757 | ||
758 | static void run_shutdown_and_kill_processes(void) | 758 | static void run_shutdown_and_kill_processes(void) |
@@ -942,7 +942,7 @@ static void reload_inittab(void) | |||
942 | for (a = G.init_action_list; a; a = a->next) | 942 | for (a = G.init_action_list; a; a = a->next) |
943 | if (a->action_type == 0 && a->pid != 0) | 943 | if (a->action_type == 0 && a->pid != 0) |
944 | kill(a->pid, SIGKILL); | 944 | kill(a->pid, SIGKILL); |
945 | _exit(EXIT_SUCCESS); | 945 | _exit_SUCCESS(); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | #endif | 948 | #endif |
diff --git a/libbb/Config.src b/libbb/Config.src index 24b31fad9..c80bee286 100644 --- a/libbb/Config.src +++ b/libbb/Config.src | |||
@@ -42,21 +42,33 @@ config MD5_SMALL | |||
42 | default 1 # all "fast or small" options default to small | 42 | default 1 # all "fast or small" options default to small |
43 | range 0 3 | 43 | range 0 3 |
44 | help | 44 | help |
45 | Trade binary size versus speed for the md5sum algorithm. | 45 | Trade binary size versus speed for the md5 algorithm. |
46 | Approximate values running uClibc and hashing | 46 | Approximate values running uClibc and hashing |
47 | linux-2.4.4.tar.bz2 were: | 47 | linux-2.4.4.tar.bz2 were: |
48 | value user times (sec) text size (386) | 48 | value user times (sec) text size (386) |
49 | 0 (fastest) 1.1 6144 | 49 | 0 (fastest) 1.1 6144 |
50 | 1 1.4 5392 | 50 | 1 1.4 5392 |
51 | 2 3.0 5088 | 51 | 2 3.0 5088 |
52 | 3 (smallest) 5.1 4912 | 52 | 3 (smallest) 5.1 4912 |
53 | |||
54 | config SHA1_SMALL | ||
55 | int "SHA1: Trade bytes for speed (0:fast, 3:slow)" | ||
56 | default 3 # all "fast or small" options default to small | ||
57 | range 0 3 | ||
58 | help | ||
59 | Trade binary size versus speed for the sha1 algorithm. | ||
60 | throughput MB/s size of sha1_process_block64 | ||
61 | value 486 x86-64 486 x86-64 | ||
62 | 0 367 375 3657 3502 | ||
63 | 1 224 229 654 732 | ||
64 | 2,3 200 195 358 380 | ||
53 | 65 | ||
54 | config SHA3_SMALL | 66 | config SHA3_SMALL |
55 | int "SHA3: Trade bytes for speed (0:fast, 1:slow)" | 67 | int "SHA3: Trade bytes for speed (0:fast, 1:slow)" |
56 | default 1 # all "fast or small" options default to small | 68 | default 1 # all "fast or small" options default to small |
57 | range 0 1 | 69 | range 0 1 |
58 | help | 70 | help |
59 | Trade binary size versus speed for the sha3sum algorithm. | 71 | Trade binary size versus speed for the sha3 algorithm. |
60 | SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate): | 72 | SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate): |
61 | 64-bit x86: +270 bytes of code, 45% faster | 73 | 64-bit x86: +270 bytes of code, 45% faster |
62 | 32-bit x86: +450 bytes of code, 75% faster | 74 | 32-bit x86: +450 bytes of code, 75% faster |
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index 9b37b174d..41bf54e75 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
@@ -45,6 +45,7 @@ lib-y += lineedit.o lineedit_ptr_hack.o | |||
45 | lib-y += llist.o | 45 | lib-y += llist.o |
46 | lib-y += make_directory.o | 46 | lib-y += make_directory.o |
47 | lib-y += hash_md5_sha.o | 47 | lib-y += hash_md5_sha.o |
48 | lib-y += hash_md5_sha_x86-64.o | ||
48 | # Alternative (disabled) MD5 implementation | 49 | # Alternative (disabled) MD5 implementation |
49 | #lib-y += hash_md5prime.o | 50 | #lib-y += hash_md5prime.o |
50 | lib-y += messages.o | 51 | lib-y += messages.o |
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c index 5df74170e..33e28ae34 100644 --- a/libbb/fflush_stdout_and_exit.c +++ b/libbb/fflush_stdout_and_exit.c | |||
@@ -13,10 +13,15 @@ | |||
13 | */ | 13 | */ |
14 | void FAST_FUNC fflush_stdout_and_exit(int retval) | 14 | void FAST_FUNC fflush_stdout_and_exit(int retval) |
15 | { | 15 | { |
16 | xfunc_error_retval = retval; | ||
17 | if (fflush(stdout)) | 16 | if (fflush(stdout)) |
18 | bb_simple_perror_msg_and_die(bb_msg_standard_output); | 17 | bb_simple_perror_msg_and_die(bb_msg_standard_output); |
18 | xfunc_error_retval = retval; | ||
19 | /* In case we are in NOFORK applet. Do not exit() directly, | 19 | /* In case we are in NOFORK applet. Do not exit() directly, |
20 | * but use xfunc_die() */ | 20 | * but use xfunc_die() */ |
21 | xfunc_die(); | 21 | xfunc_die(); |
22 | } | 22 | } |
23 | |||
24 | void FAST_FUNC fflush_stdout_and_exit_SUCCESS(void) | ||
25 | { | ||
26 | fflush_stdout_and_exit(EXIT_SUCCESS); | ||
27 | } | ||
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index e0db8ce67..ee19c1cb7 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
@@ -8,6 +8,9 @@ | |||
8 | */ | 8 | */ |
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | 10 | ||
11 | #define STR1(s) #s | ||
12 | #define STR(s) STR1(s) | ||
13 | |||
11 | #define NEED_SHA512 (ENABLE_SHA512SUM || ENABLE_USE_BB_CRYPT_SHA) | 14 | #define NEED_SHA512 (ENABLE_SHA512SUM || ENABLE_USE_BB_CRYPT_SHA) |
12 | 15 | ||
13 | /* gcc 4.2.1 optimizes rotr64 better with inline than with macro | 16 | /* gcc 4.2.1 optimizes rotr64 better with inline than with macro |
@@ -390,7 +393,6 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
390 | OP(FI, D, A, B, C, 11, 10, 0xbd3af235); | 393 | OP(FI, D, A, B, C, 11, 10, 0xbd3af235); |
391 | OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb); | 394 | OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb); |
392 | OP(FI, B, C, D, A, 9, 21, 0xeb86d391); | 395 | OP(FI, B, C, D, A, 9, 21, 0xeb86d391); |
393 | # undef OP | ||
394 | # endif | 396 | # endif |
395 | /* Add checksum to the starting values */ | 397 | /* Add checksum to the starting values */ |
396 | ctx->hash[0] += A; | 398 | ctx->hash[0] += A; |
@@ -399,6 +401,7 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx) | |||
399 | ctx->hash[3] += D; | 401 | ctx->hash[3] += D; |
400 | #endif | 402 | #endif |
401 | } | 403 | } |
404 | #undef OP | ||
402 | #undef FF | 405 | #undef FF |
403 | #undef FG | 406 | #undef FG |
404 | #undef FH | 407 | #undef FH |
@@ -490,18 +493,410 @@ unsigned FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf) | |||
490 | * then rebuild and compare "shaNNNsum bigfile" results. | 493 | * then rebuild and compare "shaNNNsum bigfile" results. |
491 | */ | 494 | */ |
492 | 495 | ||
496 | #if CONFIG_SHA1_SMALL == 0 | ||
497 | # if defined(__GNUC__) && defined(__i386__) | ||
498 | static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx UNUSED_PARAM) | ||
499 | { | ||
500 | BUILD_BUG_ON(offsetof(sha1_ctx_t, hash) != 76); | ||
501 | asm( | ||
502 | "\n\ | ||
503 | pushl %ebp # \n\ | ||
504 | pushl %edi # \n\ | ||
505 | pushl %esi # \n\ | ||
506 | pushl %ebx # \n\ | ||
507 | pushl %eax \n\ | ||
508 | movl $15, %edi \n\ | ||
509 | 1: \n\ | ||
510 | movl (%eax,%edi,4), %esi \n\ | ||
511 | bswap %esi \n\ | ||
512 | pushl %esi \n\ | ||
513 | decl %edi \n\ | ||
514 | jns 1b \n\ | ||
515 | movl 80(%eax), %ebx # b = ctx->hash[1] \n\ | ||
516 | movl 84(%eax), %ecx # c = ctx->hash[2] \n\ | ||
517 | movl 88(%eax), %edx # d = ctx->hash[3] \n\ | ||
518 | movl 92(%eax), %ebp # e = ctx->hash[4] \n\ | ||
519 | movl 76(%eax), %eax # a = ctx->hash[0] \n\ | ||
520 | #Register and stack use: \n\ | ||
521 | # eax..edx: a..d \n\ | ||
522 | # ebp: e \n\ | ||
523 | # esi,edi: temps \n\ | ||
524 | # 4*n(%esp): W[n] \n\ | ||
525 | " | ||
526 | #define RD1As(a,b,c,d,e, n, RCONST) \ | ||
527 | "\n\ | ||
528 | ##movl 4*"n"(%esp), %esi # n=0, W[0] already in %esi \n\ | ||
529 | movl "c", %edi # c \n\ | ||
530 | xorl "d", %edi # ^d \n\ | ||
531 | andl "b", %edi # &b \n\ | ||
532 | xorl "d", %edi # (((c ^ d) & b) ^ d) \n\ | ||
533 | leal "RCONST"("e",%esi), "e" # e += RCONST + W[n] \n\ | ||
534 | addl %edi, "e" # e += (((c ^ d) & b) ^ d) \n\ | ||
535 | movl "a", %esi # \n\ | ||
536 | roll $5, %esi # rotl32(a,5) \n\ | ||
537 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
538 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
539 | " | ||
540 | #define RD1Bs(a,b,c,d,e, n, RCONST) \ | ||
541 | "\n\ | ||
542 | movl 4*"n"(%esp), %esi # W[n] \n\ | ||
543 | movl "c", %edi # c \n\ | ||
544 | xorl "d", %edi # ^d \n\ | ||
545 | andl "b", %edi # &b \n\ | ||
546 | xorl "d", %edi # (((c ^ d) & b) ^ d) \n\ | ||
547 | leal "RCONST"("e",%esi), "e" # e += RCONST + W[n] \n\ | ||
548 | addl %edi, "e" # e += (((c ^ d) & b) ^ d) \n\ | ||
549 | movl "a", %esi # \n\ | ||
550 | roll $5, %esi # rotl32(a,5) \n\ | ||
551 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
552 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
553 | " | ||
554 | #define RD1Cs(a,b,c,d,e, n13,n8,n2,n, RCONST) \ | ||
555 | "\n\ | ||
556 | movl 4*"n13"(%esp), %esi # W[(n+13) & 15] \n\ | ||
557 | xorl 4*"n8"(%esp), %esi # ^W[(n+8) & 15] \n\ | ||
558 | xorl 4*"n2"(%esp), %esi # ^W[(n+2) & 15] \n\ | ||
559 | xorl 4*"n"(%esp), %esi # ^W[n & 15] \n\ | ||
560 | roll %esi # \n\ | ||
561 | movl %esi, 4*"n"(%esp) # store to W[n & 15] \n\ | ||
562 | movl "c", %edi # c \n\ | ||
563 | xorl "d", %edi # ^d \n\ | ||
564 | andl "b", %edi # &b \n\ | ||
565 | xorl "d", %edi # (((c ^ d) & b) ^ d) \n\ | ||
566 | leal "RCONST"("e",%esi), "e" # e += RCONST + mixed_W \n\ | ||
567 | addl %edi, "e" # e += (((c ^ d) & b) ^ d) \n\ | ||
568 | movl "a", %esi # \n\ | ||
569 | roll $5, %esi # rotl32(a,5) \n\ | ||
570 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
571 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
572 | " | ||
573 | #define RD1A(a,b,c,d,e, n) RD1As("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR((n)), STR(RCONST)) | ||
574 | #define RD1B(a,b,c,d,e, n) RD1Bs("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR((n)), STR(RCONST)) | ||
575 | #define RD1C(a,b,c,d,e, n) RD1Cs("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR(((n+13)&15)), STR(((n+8)&15)), STR(((n+2)&15)), STR(((n)&15)), STR(RCONST)) | ||
576 | #undef RCONST | ||
577 | #define RCONST 0x5A827999 | ||
578 | RD1A(ax,bx,cx,dx,bp, 0) RD1B(bp,ax,bx,cx,dx, 1) RD1B(dx,bp,ax,bx,cx, 2) RD1B(cx,dx,bp,ax,bx, 3) RD1B(bx,cx,dx,bp,ax, 4) | ||
579 | RD1B(ax,bx,cx,dx,bp, 5) RD1B(bp,ax,bx,cx,dx, 6) RD1B(dx,bp,ax,bx,cx, 7) RD1B(cx,dx,bp,ax,bx, 8) RD1B(bx,cx,dx,bp,ax, 9) | ||
580 | RD1B(ax,bx,cx,dx,bp,10) RD1B(bp,ax,bx,cx,dx,11) RD1B(dx,bp,ax,bx,cx,12) RD1B(cx,dx,bp,ax,bx,13) RD1B(bx,cx,dx,bp,ax,14) | ||
581 | RD1B(ax,bx,cx,dx,bp,15) RD1C(bp,ax,bx,cx,dx,16) RD1C(dx,bp,ax,bx,cx,17) RD1C(cx,dx,bp,ax,bx,18) RD1C(bx,cx,dx,bp,ax,19) | ||
582 | #define RD2s(a,b,c,d,e, n13,n8,n2,n, RCONST) \ | ||
583 | "\n\ | ||
584 | movl 4*"n13"(%esp), %esi # W[(n+13) & 15] \n\ | ||
585 | xorl 4*"n8"(%esp), %esi # ^W[(n+8) & 15] \n\ | ||
586 | xorl 4*"n2"(%esp), %esi # ^W[(n+2) & 15] \n\ | ||
587 | xorl 4*"n"(%esp), %esi # ^W[n & 15] \n\ | ||
588 | roll %esi # \n\ | ||
589 | movl %esi, 4*"n"(%esp) # store to W[n & 15] \n\ | ||
590 | movl "c", %edi # c \n\ | ||
591 | xorl "d", %edi # ^d \n\ | ||
592 | xorl "b", %edi # ^b \n\ | ||
593 | leal "RCONST"("e",%esi), "e" # e += RCONST + mixed_W \n\ | ||
594 | addl %edi, "e" # e += (c ^ d ^ b) \n\ | ||
595 | movl "a", %esi # \n\ | ||
596 | roll $5, %esi # rotl32(a,5) \n\ | ||
597 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
598 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
599 | " | ||
600 | #define RD2(a,b,c,d,e, n) RD2s("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR(((20+n+13)&15)), STR(((20+n+8)&15)), STR(((20+n+2)&15)), STR(((20+n)&15)), STR(RCONST)) | ||
601 | #undef RCONST | ||
602 | #define RCONST 0x6ED9EBA1 | ||
603 | RD2(ax,bx,cx,dx,bp, 0) RD2(bp,ax,bx,cx,dx, 1) RD2(dx,bp,ax,bx,cx, 2) RD2(cx,dx,bp,ax,bx, 3) RD2(bx,cx,dx,bp,ax, 4) | ||
604 | RD2(ax,bx,cx,dx,bp, 5) RD2(bp,ax,bx,cx,dx, 6) RD2(dx,bp,ax,bx,cx, 7) RD2(cx,dx,bp,ax,bx, 8) RD2(bx,cx,dx,bp,ax, 9) | ||
605 | RD2(ax,bx,cx,dx,bp,10) RD2(bp,ax,bx,cx,dx,11) RD2(dx,bp,ax,bx,cx,12) RD2(cx,dx,bp,ax,bx,13) RD2(bx,cx,dx,bp,ax,14) | ||
606 | RD2(ax,bx,cx,dx,bp,15) RD2(bp,ax,bx,cx,dx,16) RD2(dx,bp,ax,bx,cx,17) RD2(cx,dx,bp,ax,bx,18) RD2(bx,cx,dx,bp,ax,19) | ||
607 | |||
608 | #define RD3s(a,b,c,d,e, n13,n8,n2,n, RCONST) \ | ||
609 | "\n\ | ||
610 | movl "b", %edi # di: b \n\ | ||
611 | movl "b", %esi # si: b \n\ | ||
612 | orl "c", %edi # di: b | c \n\ | ||
613 | andl "c", %esi # si: b & c \n\ | ||
614 | andl "d", %edi # di: (b | c) & d \n\ | ||
615 | orl %esi, %edi # ((b | c) & d) | (b & c) \n\ | ||
616 | movl 4*"n13"(%esp), %esi # W[(n+13) & 15] \n\ | ||
617 | xorl 4*"n8"(%esp), %esi # ^W[(n+8) & 15] \n\ | ||
618 | xorl 4*"n2"(%esp), %esi # ^W[(n+2) & 15] \n\ | ||
619 | xorl 4*"n"(%esp), %esi # ^W[n & 15] \n\ | ||
620 | roll %esi # \n\ | ||
621 | movl %esi, 4*"n"(%esp) # store to W[n & 15] \n\ | ||
622 | addl %edi, "e" # += ((b | c) & d) | (b & c)\n\ | ||
623 | leal "RCONST"("e",%esi), "e" # e += RCONST + mixed_W \n\ | ||
624 | movl "a", %esi # \n\ | ||
625 | roll $5, %esi # rotl32(a,5) \n\ | ||
626 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
627 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
628 | " | ||
629 | #define RD3(a,b,c,d,e, n) RD3s("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR(((40+n+13)&15)), STR(((40+n+8)&15)), STR(((40+n+2)&15)), STR(((40+n)&15)), STR(RCONST)) | ||
630 | #undef RCONST | ||
631 | #define RCONST 0x8F1BBCDC | ||
632 | RD3(ax,bx,cx,dx,bp, 0) RD3(bp,ax,bx,cx,dx, 1) RD3(dx,bp,ax,bx,cx, 2) RD3(cx,dx,bp,ax,bx, 3) RD3(bx,cx,dx,bp,ax, 4) | ||
633 | RD3(ax,bx,cx,dx,bp, 5) RD3(bp,ax,bx,cx,dx, 6) RD3(dx,bp,ax,bx,cx, 7) RD3(cx,dx,bp,ax,bx, 8) RD3(bx,cx,dx,bp,ax, 9) | ||
634 | RD3(ax,bx,cx,dx,bp,10) RD3(bp,ax,bx,cx,dx,11) RD3(dx,bp,ax,bx,cx,12) RD3(cx,dx,bp,ax,bx,13) RD3(bx,cx,dx,bp,ax,14) | ||
635 | RD3(ax,bx,cx,dx,bp,15) RD3(bp,ax,bx,cx,dx,16) RD3(dx,bp,ax,bx,cx,17) RD3(cx,dx,bp,ax,bx,18) RD3(bx,cx,dx,bp,ax,19) | ||
636 | |||
637 | #define RD4As(a,b,c,d,e, n13,n8,n2,n, RCONST) \ | ||
638 | "\n\ | ||
639 | movl 4*"n13"(%esp), %esi # W[(n+13) & 15] \n\ | ||
640 | xorl 4*"n8"(%esp), %esi # ^W[(n+8) & 15] \n\ | ||
641 | xorl 4*"n2"(%esp), %esi # ^W[(n+2) & 15] \n\ | ||
642 | xorl 4*"n"(%esp), %esi # ^W[n & 15] \n\ | ||
643 | roll %esi # \n\ | ||
644 | movl %esi, 4*"n"(%esp) # store to W[n & 15] \n\ | ||
645 | movl "c", %edi # c \n\ | ||
646 | xorl "d", %edi # ^d \n\ | ||
647 | xorl "b", %edi # ^b \n\ | ||
648 | leal "RCONST"("e",%esi), "e" # e += RCONST + mixed_W \n\ | ||
649 | addl %edi, "e" # e += (c ^ d ^ b) \n\ | ||
650 | movl "a", %esi # \n\ | ||
651 | roll $5, %esi # rotl32(a,5) \n\ | ||
652 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
653 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
654 | " | ||
655 | #define RD4Bs(a,b,c,d,e, n13,n8,n2,n, RCONST) \ | ||
656 | "\n\ | ||
657 | movl 4*"n13"(%esp), %esi # W[(n+13) & 15] \n\ | ||
658 | xorl 4*"n8"(%esp), %esi # ^W[(n+8) & 15] \n\ | ||
659 | xorl 4*"n2"(%esp), %esi # ^W[(n+2) & 15] \n\ | ||
660 | xorl 4*"n"(%esp), %esi # ^W[n & 15] \n\ | ||
661 | roll %esi # \n\ | ||
662 | ##movl %esi, 4*"n"(%esp) # store to W[n & 15] elided \n\ | ||
663 | movl "c", %edi # c \n\ | ||
664 | xorl "d", %edi # ^d \n\ | ||
665 | xorl "b", %edi # ^b \n\ | ||
666 | leal "RCONST"("e",%esi), "e" # e += RCONST + mixed_W \n\ | ||
667 | addl %edi, "e" # e += (c ^ d ^ b) \n\ | ||
668 | movl "a", %esi # \n\ | ||
669 | roll $5, %esi # rotl32(a,5) \n\ | ||
670 | addl %esi, "e" # e += rotl32(a,5) \n\ | ||
671 | rorl $2, "b" # b = rotl32(b,30) \n\ | ||
672 | " | ||
673 | #define RD4A(a,b,c,d,e, n) RD4As("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR(((60+n+13)&15)), STR(((60+n+8)&15)), STR(((60+n+2)&15)), STR(((60+n)&15)), STR(RCONST)) | ||
674 | #define RD4B(a,b,c,d,e, n) RD4Bs("%e"STR(a),"%e"STR(b),"%e"STR(c),"%e"STR(d),"%e"STR(e), STR(((60+n+13)&15)), STR(((60+n+8)&15)), STR(((60+n+2)&15)), STR(((60+n)&15)), STR(RCONST)) | ||
675 | #undef RCONST | ||
676 | #define RCONST 0xCA62C1D6 | ||
677 | RD4A(ax,bx,cx,dx,bp, 0) RD4A(bp,ax,bx,cx,dx, 1) RD4A(dx,bp,ax,bx,cx, 2) RD4A(cx,dx,bp,ax,bx, 3) RD4A(bx,cx,dx,bp,ax, 4) | ||
678 | RD4A(ax,bx,cx,dx,bp, 5) RD4A(bp,ax,bx,cx,dx, 6) RD4A(dx,bp,ax,bx,cx, 7) RD4A(cx,dx,bp,ax,bx, 8) RD4A(bx,cx,dx,bp,ax, 9) | ||
679 | RD4A(ax,bx,cx,dx,bp,10) RD4A(bp,ax,bx,cx,dx,11) RD4A(dx,bp,ax,bx,cx,12) RD4A(cx,dx,bp,ax,bx,13) RD4A(bx,cx,dx,bp,ax,14) | ||
680 | RD4A(ax,bx,cx,dx,bp,15) RD4A(bp,ax,bx,cx,dx,16) RD4B(dx,bp,ax,bx,cx,17) RD4B(cx,dx,bp,ax,bx,18) RD4B(bx,cx,dx,bp,ax,19) | ||
681 | |||
682 | "\n\ | ||
683 | movl 4*16(%esp), %esi # \n\ | ||
684 | addl $4*(16+1), %esp # \n\ | ||
685 | addl %eax, 76(%esi) # ctx->hash[0] += a \n\ | ||
686 | addl %ebx, 80(%esi) # ctx->hash[1] += b \n\ | ||
687 | addl %ecx, 84(%esi) # ctx->hash[2] += c \n\ | ||
688 | addl %edx, 88(%esi) # ctx->hash[3] += d \n\ | ||
689 | addl %ebp, 92(%esi) # ctx->hash[4] += e \n\ | ||
690 | popl %ebx # \n\ | ||
691 | popl %esi # \n\ | ||
692 | popl %edi # \n\ | ||
693 | popl %ebp # \n\ | ||
694 | " | ||
695 | ); /* asm */ | ||
696 | #undef RCONST | ||
697 | } | ||
698 | # elif defined(__GNUC__) && defined(__x86_64__) | ||
699 | |||
700 | /* in hash_md5_sha_x86-64.S */ | ||
701 | struct ASM_expects_80 { char t[1 - 2*(offsetof(sha1_ctx_t, hash) != 80)]; }; | ||
702 | void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx UNUSED_PARAM); | ||
703 | |||
704 | # else | ||
705 | /* Fast, fully-unrolled SHA1. +3800 bytes of code on x86. | ||
706 | * It seems further speedup can be achieved by handling more than | ||
707 | * 64 bytes per one function call (coreutils does that). | ||
708 | */ | ||
709 | static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | ||
710 | { | ||
711 | static const uint32_t rconsts[] ALIGN4 = { | ||
712 | 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 | ||
713 | }; | ||
714 | uint32_t W[16]; | ||
715 | uint32_t a, b, c, d, e; | ||
716 | |||
717 | a = ctx->hash[0]; | ||
718 | b = ctx->hash[1]; | ||
719 | c = ctx->hash[2]; | ||
720 | d = ctx->hash[3]; | ||
721 | e = ctx->hash[4]; | ||
722 | |||
723 | /* From kernel source comments: | ||
724 | * """ | ||
725 | * If you have 32 registers or more, the compiler can (and should) | ||
726 | * try to change the array[] accesses into registers. However, on | ||
727 | * machines with less than ~25 registers, that won't really work, | ||
728 | * and at least gcc will make an unholy mess of it. | ||
729 | * | ||
730 | * So to avoid that mess which just slows things down, we force | ||
731 | * the stores to memory to actually happen (we might be better off | ||
732 | * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as | ||
733 | * suggested by Artur Skawina - that will also make gcc unable to | ||
734 | * try to do the silly "optimize away loads" part because it won't | ||
735 | * see what the value will be). | ||
736 | * """ | ||
737 | */ | ||
738 | #if defined(__GNUC__) && defined(__i386__) | ||
739 | # define DO_NOT_TRY_PROPAGATING(m) asm("":"+m"(m)) | ||
740 | #else | ||
741 | # define DO_NOT_TRY_PROPAGATING(m) ((void)0) | ||
742 | #endif | ||
743 | |||
744 | #undef OP | ||
745 | #define OP(A,B,C,D,E, n) \ | ||
746 | do { \ | ||
747 | uint32_t work = EXPR(B, C, D); \ | ||
748 | if (n <= 15) \ | ||
749 | work += W[n & 15] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[n]); \ | ||
750 | if (n >= 16) \ | ||
751 | work += W[n & 15] = rotl32(W[(n+13) & 15] ^ W[(n+8) & 15] ^ W[(n+2) & 15] ^ W[n & 15], 1); \ | ||
752 | DO_NOT_TRY_PROPAGATING(W[n & 15]); \ | ||
753 | E += work + rotl32(A, 5) + rconsts[n / 20]; \ | ||
754 | B = rotl32(B, 30); \ | ||
755 | } while (0) | ||
756 | #define OP20(n) \ | ||
757 | OP(a,b,c,d,e, (n+ 0)); OP(e,a,b,c,d, (n+ 1)); OP(d,e,a,b,c, (n+ 2)); OP(c,d,e,a,b, (n+ 3)); OP(b,c,d,e,a, (n+ 4)); \ | ||
758 | OP(a,b,c,d,e, (n+ 5)); OP(e,a,b,c,d, (n+ 6)); OP(d,e,a,b,c, (n+ 7)); OP(c,d,e,a,b, (n+ 8)); OP(b,c,d,e,a, (n+ 9)); \ | ||
759 | OP(a,b,c,d,e, (n+10)); OP(e,a,b,c,d, (n+11)); OP(d,e,a,b,c, (n+12)); OP(c,d,e,a,b, (n+13)); OP(b,c,d,e,a, (n+14)); \ | ||
760 | OP(a,b,c,d,e, (n+15)); OP(e,a,b,c,d, (n+16)); OP(d,e,a,b,c, (n+17)); OP(c,d,e,a,b, (n+18)); OP(b,c,d,e,a, (n+19)) | ||
761 | |||
762 | /* 4 rounds of 20 operations each */ | ||
763 | #define EXPR(b,c,d) (((c ^ d) & b) ^ d) | ||
764 | OP20(0); | ||
765 | #undef EXPR | ||
766 | #define EXPR(b,c,d) (c ^ d ^ b) | ||
767 | OP20(20); | ||
768 | #undef EXPR | ||
769 | #define EXPR(b,c,d) (((b | c) & d) | (b & c)) | ||
770 | OP20(40); | ||
771 | #undef EXPR | ||
772 | #define EXPR(b,c,d) (c ^ d ^ b) | ||
773 | OP20(60); | ||
774 | |||
775 | #undef EXPR | ||
776 | #undef OP | ||
777 | #undef OP20 | ||
778 | |||
779 | ctx->hash[0] += a; | ||
780 | ctx->hash[1] += b; | ||
781 | ctx->hash[2] += c; | ||
782 | ctx->hash[3] += d; | ||
783 | ctx->hash[4] += e; | ||
784 | } | ||
785 | # endif | ||
786 | #elif CONFIG_SHA1_SMALL == 1 | ||
787 | /* Middle-sized version, +300 bytes of code on x86. */ | ||
788 | static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | ||
789 | { | ||
790 | static const uint32_t rconsts[] ALIGN4 = { | ||
791 | 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 | ||
792 | }; | ||
793 | int j; | ||
794 | int n; | ||
795 | uint32_t W[16+16]; | ||
796 | uint32_t a, b, c, d, e; | ||
797 | |||
798 | a = ctx->hash[0]; | ||
799 | b = ctx->hash[1]; | ||
800 | c = ctx->hash[2]; | ||
801 | d = ctx->hash[3]; | ||
802 | e = ctx->hash[4]; | ||
803 | |||
804 | /* 1st round of 20 operations */ | ||
805 | n = 0; | ||
806 | do { | ||
807 | uint32_t work = ((c ^ d) & b) ^ d; | ||
808 | W[n] = W[n+16] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[n]); | ||
809 | work += W[n]; | ||
810 | work += e + rotl32(a, 5) + rconsts[0]; | ||
811 | /* Rotate by one for next time */ | ||
812 | e = d; | ||
813 | d = c; | ||
814 | c = rotl32(b, 30); | ||
815 | b = a; | ||
816 | a = work; | ||
817 | n = (n + 1) & 15; | ||
818 | } while (n != 0); | ||
819 | do { | ||
820 | uint32_t work = ((c ^ d) & b) ^ d; | ||
821 | W[n] = W[n+16] = rotl32(W[n+13] ^ W[n+8] ^ W[n+2] ^ W[n], 1); | ||
822 | work += W[n]; | ||
823 | work += e + rotl32(a, 5) + rconsts[0]; | ||
824 | e = d; | ||
825 | d = c; | ||
826 | c = rotl32(b, 30); | ||
827 | b = a; | ||
828 | a = work; | ||
829 | n = (n + 1) /* & 15*/; | ||
830 | } while (n != 4); | ||
831 | /* 2nd round of 20 operations */ | ||
832 | j = 19; | ||
833 | do { | ||
834 | uint32_t work = c ^ d ^ b; | ||
835 | W[n] = W[n+16] = rotl32(W[n+13] ^ W[n+8] ^ W[n+2] ^ W[n], 1); | ||
836 | work += W[n]; | ||
837 | work += e + rotl32(a, 5) + rconsts[1]; | ||
838 | e = d; | ||
839 | d = c; | ||
840 | c = rotl32(b, 30); | ||
841 | b = a; | ||
842 | a = work; | ||
843 | n = (n + 1) & 15; | ||
844 | } while (--j >= 0); | ||
845 | /* 3rd round */ | ||
846 | j = 19; | ||
847 | do { | ||
848 | uint32_t work = ((b | c) & d) | (b & c); | ||
849 | W[n] = W[n+16] = rotl32(W[n+13] ^ W[n+8] ^ W[n+2] ^ W[n], 1); | ||
850 | work += W[n]; | ||
851 | work += e + rotl32(a, 5) + rconsts[2]; | ||
852 | e = d; | ||
853 | d = c; | ||
854 | c = rotl32(b, 30); | ||
855 | b = a; | ||
856 | a = work; | ||
857 | n = (n + 1) & 15; | ||
858 | } while (--j >= 0); | ||
859 | /* 4th round */ | ||
860 | j = 19; | ||
861 | do { | ||
862 | uint32_t work = c ^ d ^ b; | ||
863 | W[n] = W[n+16] = rotl32(W[n+13] ^ W[n+8] ^ W[n+2] ^ W[n], 1); | ||
864 | work += W[n]; | ||
865 | work += e + rotl32(a, 5) + rconsts[3]; | ||
866 | e = d; | ||
867 | d = c; | ||
868 | c = rotl32(b, 30); | ||
869 | b = a; | ||
870 | a = work; | ||
871 | n = (n + 1) & 15; | ||
872 | } while (--j >= 0); | ||
873 | |||
874 | ctx->hash[0] += a; | ||
875 | ctx->hash[1] += b; | ||
876 | ctx->hash[2] += c; | ||
877 | ctx->hash[3] += d; | ||
878 | ctx->hash[4] += e; | ||
879 | } | ||
880 | #else | ||
881 | /* Compact version, almost twice as slow as fully unrolled */ | ||
493 | static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | 882 | static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) |
494 | { | 883 | { |
495 | static const uint32_t rconsts[] ALIGN4 = { | 884 | static const uint32_t rconsts[] ALIGN4 = { |
496 | 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 | 885 | 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 |
497 | }; | 886 | }; |
498 | int i, j; | 887 | int i, j; |
499 | int cnt; | 888 | int n; |
500 | uint32_t W[16+16]; | 889 | uint32_t W[16+16]; |
501 | uint32_t a, b, c, d, e; | 890 | uint32_t a, b, c, d, e; |
502 | 891 | ||
503 | /* On-stack work buffer frees up one register in the main loop | 892 | /* On-stack work buffer frees up one register in the main loop |
504 | * which otherwise will be needed to hold ctx pointer */ | 893 | * which otherwise will be needed to hold ctx pointer. |
894 | * | ||
895 | * The compiler is not smart enough to realize it, though. :( | ||
896 | * If __attribute__((optimize("2"))) is added to the function, | ||
897 | * only then gcc-9.3.1 spills "ctx" to stack and uses the freed | ||
898 | * register (making code 6 bytes smaller, not just faster). | ||
899 | */ | ||
505 | for (i = 0; i < 16; i++) | 900 | for (i = 0; i < 16; i++) |
506 | W[i] = W[i+16] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[i]); | 901 | W[i] = W[i+16] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[i]); |
507 | 902 | ||
@@ -512,7 +907,7 @@ static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | |||
512 | e = ctx->hash[4]; | 907 | e = ctx->hash[4]; |
513 | 908 | ||
514 | /* 4 rounds of 20 operations each */ | 909 | /* 4 rounds of 20 operations each */ |
515 | cnt = 0; | 910 | n = 0; |
516 | for (i = 0; i < 4; i++) { | 911 | for (i = 0; i < 4; i++) { |
517 | j = 19; | 912 | j = 19; |
518 | do { | 913 | do { |
@@ -523,27 +918,24 @@ static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | |||
523 | work = (work & b) ^ d; | 918 | work = (work & b) ^ d; |
524 | if (j <= 3) | 919 | if (j <= 3) |
525 | goto ge16; | 920 | goto ge16; |
526 | /* Used to do SWAP_BE32 here, but this | ||
527 | * requires ctx (see comment above) */ | ||
528 | work += W[cnt]; | ||
529 | } else { | 921 | } else { |
530 | if (i == 2) | 922 | if (i == 2) |
531 | work = ((b | c) & d) | (b & c); | 923 | work = ((b | c) & d) | (b & c); |
532 | else /* i = 1 or 3 */ | 924 | else /* i = 1 or 3 */ |
533 | work ^= b; | 925 | work ^= b; |
534 | ge16: | 926 | ge16: |
535 | W[cnt] = W[cnt+16] = rotl32(W[cnt+13] ^ W[cnt+8] ^ W[cnt+2] ^ W[cnt], 1); | 927 | W[n] = W[n+16] = rotl32(W[n+13] ^ W[n+8] ^ W[n+2] ^ W[n], 1); |
536 | work += W[cnt]; | ||
537 | } | 928 | } |
929 | work += W[n]; | ||
538 | work += e + rotl32(a, 5) + rconsts[i]; | 930 | work += e + rotl32(a, 5) + rconsts[i]; |
539 | 931 | ||
540 | /* Rotate by one for next time */ | 932 | /* Rotate by one for next time */ |
541 | e = d; | 933 | e = d; |
542 | d = c; | 934 | d = c; |
543 | c = /* b = */ rotl32(b, 30); | 935 | c = rotl32(b, 30); |
544 | b = a; | 936 | b = a; |
545 | a = work; | 937 | a = work; |
546 | cnt = (cnt + 1) & 15; | 938 | n = (n + 1) & 15; |
547 | } while (--j >= 0); | 939 | } while (--j >= 0); |
548 | } | 940 | } |
549 | 941 | ||
@@ -553,6 +945,7 @@ static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | |||
553 | ctx->hash[3] += d; | 945 | ctx->hash[3] += d; |
554 | ctx->hash[4] += e; | 946 | ctx->hash[4] += e; |
555 | } | 947 | } |
948 | #endif | ||
556 | 949 | ||
557 | /* Constants for SHA512 from FIPS 180-2:4.2.3. | 950 | /* Constants for SHA512 from FIPS 180-2:4.2.3. |
558 | * SHA256 constants from FIPS 180-2:4.2.2 | 951 | * SHA256 constants from FIPS 180-2:4.2.2 |
diff --git a/libbb/hash_md5_sha_x86-64.S b/libbb/hash_md5_sha_x86-64.S new file mode 100644 index 000000000..ff78fc049 --- /dev/null +++ b/libbb/hash_md5_sha_x86-64.S | |||
@@ -0,0 +1,1289 @@ | |||
1 | ### Generated by hash_md5_sha_x86-64.S.sh ### | ||
2 | |||
3 | #if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) | ||
4 | .section .text.sha1_process_block64,"ax",@progbits | ||
5 | .globl sha1_process_block64 | ||
6 | .hidden sha1_process_block64 | ||
7 | .type sha1_process_block64, @function | ||
8 | |||
9 | .balign 8 # allow decoders to fetch at least 5 first insns | ||
10 | sha1_process_block64: | ||
11 | pushq %rbp # 1 byte insn | ||
12 | pushq %rbx # 1 byte insn | ||
13 | pushq %r15 # 2 byte insn | ||
14 | pushq %r14 # 2 byte insn | ||
15 | pushq %r13 # 2 byte insn | ||
16 | pushq %r12 # 2 byte insn | ||
17 | pushq %rdi # we need ctx at the end | ||
18 | |||
19 | #Register and stack use: | ||
20 | # eax..edx: a..d | ||
21 | # ebp: e | ||
22 | # esi,edi: temps | ||
23 | # -32+4*n(%rsp),r8...r15: W[0..7,8..15] | ||
24 | # (TODO: actually W[0..7] are used a bit more often, put _them_ into r8..r15?) | ||
25 | movl $3, %eax | ||
26 | 1: | ||
27 | movq (%rdi,%rax,8), %rsi | ||
28 | bswapq %rsi | ||
29 | rolq $32, %rsi | ||
30 | movq %rsi, -32(%rsp,%rax,8) | ||
31 | decl %eax | ||
32 | jns 1b | ||
33 | |||
34 | movl 80(%rdi), %eax # a = ctx->hash[0] | ||
35 | movl 84(%rdi), %ebx # b = ctx->hash[1] | ||
36 | movl 88(%rdi), %ecx # c = ctx->hash[2] | ||
37 | movl 92(%rdi), %edx # d = ctx->hash[3] | ||
38 | movl 96(%rdi), %ebp # e = ctx->hash[4] | ||
39 | |||
40 | movq 4*8(%rdi), %r8 | ||
41 | movq 4*10(%rdi), %r10 | ||
42 | bswapq %r8 | ||
43 | bswapq %r10 | ||
44 | movq 4*12(%rdi), %r12 | ||
45 | movq 4*14(%rdi), %r14 | ||
46 | bswapq %r12 | ||
47 | bswapq %r14 | ||
48 | movl %r8d, %r9d | ||
49 | shrq $32, %r8 | ||
50 | movl %r10d, %r11d | ||
51 | shrq $32, %r10 | ||
52 | movl %r12d, %r13d | ||
53 | shrq $32, %r12 | ||
54 | movl %r14d, %r15d | ||
55 | shrq $32, %r14 | ||
56 | |||
57 | # 0 | ||
58 | # W[0], already in %esi | ||
59 | movl %ecx, %edi # c | ||
60 | xorl %edx, %edi # ^d | ||
61 | andl %ebx, %edi # &b | ||
62 | xorl %edx, %edi # (((c ^ d) & b) ^ d) | ||
63 | leal 0x5A827999(%rbp,%rsi), %ebp # e += RCONST + W[n] | ||
64 | addl %edi, %ebp # e += (((c ^ d) & b) ^ d) | ||
65 | movl %eax, %esi # | ||
66 | roll $5, %esi # rotl32(a,5) | ||
67 | addl %esi, %ebp # e += rotl32(a,5) | ||
68 | rorl $2, %ebx # b = rotl32(b,30) | ||
69 | # 1 | ||
70 | movl -32+4*1(%rsp), %esi # W[n] | ||
71 | movl %ebx, %edi # c | ||
72 | xorl %ecx, %edi # ^d | ||
73 | andl %eax, %edi # &b | ||
74 | xorl %ecx, %edi # (((c ^ d) & b) ^ d) | ||
75 | leal 0x5A827999(%rdx,%rsi), %edx # e += RCONST + W[n] | ||
76 | addl %edi, %edx # e += (((c ^ d) & b) ^ d) | ||
77 | movl %ebp, %esi # | ||
78 | roll $5, %esi # rotl32(a,5) | ||
79 | addl %esi, %edx # e += rotl32(a,5) | ||
80 | rorl $2, %eax # b = rotl32(b,30) | ||
81 | # 2 | ||
82 | movl -32+4*2(%rsp), %esi # W[n] | ||
83 | movl %eax, %edi # c | ||
84 | xorl %ebx, %edi # ^d | ||
85 | andl %ebp, %edi # &b | ||
86 | xorl %ebx, %edi # (((c ^ d) & b) ^ d) | ||
87 | leal 0x5A827999(%rcx,%rsi), %ecx # e += RCONST + W[n] | ||
88 | addl %edi, %ecx # e += (((c ^ d) & b) ^ d) | ||
89 | movl %edx, %esi # | ||
90 | roll $5, %esi # rotl32(a,5) | ||
91 | addl %esi, %ecx # e += rotl32(a,5) | ||
92 | rorl $2, %ebp # b = rotl32(b,30) | ||
93 | # 3 | ||
94 | movl -32+4*3(%rsp), %esi # W[n] | ||
95 | movl %ebp, %edi # c | ||
96 | xorl %eax, %edi # ^d | ||
97 | andl %edx, %edi # &b | ||
98 | xorl %eax, %edi # (((c ^ d) & b) ^ d) | ||
99 | leal 0x5A827999(%rbx,%rsi), %ebx # e += RCONST + W[n] | ||
100 | addl %edi, %ebx # e += (((c ^ d) & b) ^ d) | ||
101 | movl %ecx, %esi # | ||
102 | roll $5, %esi # rotl32(a,5) | ||
103 | addl %esi, %ebx # e += rotl32(a,5) | ||
104 | rorl $2, %edx # b = rotl32(b,30) | ||
105 | # 4 | ||
106 | movl -32+4*4(%rsp), %esi # W[n] | ||
107 | movl %edx, %edi # c | ||
108 | xorl %ebp, %edi # ^d | ||
109 | andl %ecx, %edi # &b | ||
110 | xorl %ebp, %edi # (((c ^ d) & b) ^ d) | ||
111 | leal 0x5A827999(%rax,%rsi), %eax # e += RCONST + W[n] | ||
112 | addl %edi, %eax # e += (((c ^ d) & b) ^ d) | ||
113 | movl %ebx, %esi # | ||
114 | roll $5, %esi # rotl32(a,5) | ||
115 | addl %esi, %eax # e += rotl32(a,5) | ||
116 | rorl $2, %ecx # b = rotl32(b,30) | ||
117 | # 5 | ||
118 | movl -32+4*5(%rsp), %esi # W[n] | ||
119 | movl %ecx, %edi # c | ||
120 | xorl %edx, %edi # ^d | ||
121 | andl %ebx, %edi # &b | ||
122 | xorl %edx, %edi # (((c ^ d) & b) ^ d) | ||
123 | leal 0x5A827999(%rbp,%rsi), %ebp # e += RCONST + W[n] | ||
124 | addl %edi, %ebp # e += (((c ^ d) & b) ^ d) | ||
125 | movl %eax, %esi # | ||
126 | roll $5, %esi # rotl32(a,5) | ||
127 | addl %esi, %ebp # e += rotl32(a,5) | ||
128 | rorl $2, %ebx # b = rotl32(b,30) | ||
129 | # 6 | ||
130 | movl -32+4*6(%rsp), %esi # W[n] | ||
131 | movl %ebx, %edi # c | ||
132 | xorl %ecx, %edi # ^d | ||
133 | andl %eax, %edi # &b | ||
134 | xorl %ecx, %edi # (((c ^ d) & b) ^ d) | ||
135 | leal 0x5A827999(%rdx,%rsi), %edx # e += RCONST + W[n] | ||
136 | addl %edi, %edx # e += (((c ^ d) & b) ^ d) | ||
137 | movl %ebp, %esi # | ||
138 | roll $5, %esi # rotl32(a,5) | ||
139 | addl %esi, %edx # e += rotl32(a,5) | ||
140 | rorl $2, %eax # b = rotl32(b,30) | ||
141 | # 7 | ||
142 | movl -32+4*7(%rsp), %esi # W[n] | ||
143 | movl %eax, %edi # c | ||
144 | xorl %ebx, %edi # ^d | ||
145 | andl %ebp, %edi # &b | ||
146 | xorl %ebx, %edi # (((c ^ d) & b) ^ d) | ||
147 | leal 0x5A827999(%rcx,%rsi), %ecx # e += RCONST + W[n] | ||
148 | addl %edi, %ecx # e += (((c ^ d) & b) ^ d) | ||
149 | movl %edx, %esi # | ||
150 | roll $5, %esi # rotl32(a,5) | ||
151 | addl %esi, %ecx # e += rotl32(a,5) | ||
152 | rorl $2, %ebp # b = rotl32(b,30) | ||
153 | # 8 | ||
154 | # W[n], in %r8 | ||
155 | movl %ebp, %edi # c | ||
156 | xorl %eax, %edi # ^d | ||
157 | andl %edx, %edi # &b | ||
158 | xorl %eax, %edi # (((c ^ d) & b) ^ d) | ||
159 | leal 0x5A827999(%rbx,%r8), %ebx # e += RCONST + W[n] | ||
160 | addl %edi, %ebx # e += (((c ^ d) & b) ^ d) | ||
161 | movl %ecx, %esi # | ||
162 | roll $5, %esi # rotl32(a,5) | ||
163 | addl %esi, %ebx # e += rotl32(a,5) | ||
164 | rorl $2, %edx # b = rotl32(b,30) | ||
165 | # 9 | ||
166 | # W[n], in %r9 | ||
167 | movl %edx, %edi # c | ||
168 | xorl %ebp, %edi # ^d | ||
169 | andl %ecx, %edi # &b | ||
170 | xorl %ebp, %edi # (((c ^ d) & b) ^ d) | ||
171 | leal 0x5A827999(%rax,%r9), %eax # e += RCONST + W[n] | ||
172 | addl %edi, %eax # e += (((c ^ d) & b) ^ d) | ||
173 | movl %ebx, %esi # | ||
174 | roll $5, %esi # rotl32(a,5) | ||
175 | addl %esi, %eax # e += rotl32(a,5) | ||
176 | rorl $2, %ecx # b = rotl32(b,30) | ||
177 | # 10 | ||
178 | # W[n], in %r10 | ||
179 | movl %ecx, %edi # c | ||
180 | xorl %edx, %edi # ^d | ||
181 | andl %ebx, %edi # &b | ||
182 | xorl %edx, %edi # (((c ^ d) & b) ^ d) | ||
183 | leal 0x5A827999(%rbp,%r10), %ebp # e += RCONST + W[n] | ||
184 | addl %edi, %ebp # e += (((c ^ d) & b) ^ d) | ||
185 | movl %eax, %esi # | ||
186 | roll $5, %esi # rotl32(a,5) | ||
187 | addl %esi, %ebp # e += rotl32(a,5) | ||
188 | rorl $2, %ebx # b = rotl32(b,30) | ||
189 | # 11 | ||
190 | # W[n], in %r11 | ||
191 | movl %ebx, %edi # c | ||
192 | xorl %ecx, %edi # ^d | ||
193 | andl %eax, %edi # &b | ||
194 | xorl %ecx, %edi # (((c ^ d) & b) ^ d) | ||
195 | leal 0x5A827999(%rdx,%r11), %edx # e += RCONST + W[n] | ||
196 | addl %edi, %edx # e += (((c ^ d) & b) ^ d) | ||
197 | movl %ebp, %esi # | ||
198 | roll $5, %esi # rotl32(a,5) | ||
199 | addl %esi, %edx # e += rotl32(a,5) | ||
200 | rorl $2, %eax # b = rotl32(b,30) | ||
201 | # 12 | ||
202 | # W[n], in %r12 | ||
203 | movl %eax, %edi # c | ||
204 | xorl %ebx, %edi # ^d | ||
205 | andl %ebp, %edi # &b | ||
206 | xorl %ebx, %edi # (((c ^ d) & b) ^ d) | ||
207 | leal 0x5A827999(%rcx,%r12), %ecx # e += RCONST + W[n] | ||
208 | addl %edi, %ecx # e += (((c ^ d) & b) ^ d) | ||
209 | movl %edx, %esi # | ||
210 | roll $5, %esi # rotl32(a,5) | ||
211 | addl %esi, %ecx # e += rotl32(a,5) | ||
212 | rorl $2, %ebp # b = rotl32(b,30) | ||
213 | # 13 | ||
214 | # W[n], in %r13 | ||
215 | movl %ebp, %edi # c | ||
216 | xorl %eax, %edi # ^d | ||
217 | andl %edx, %edi # &b | ||
218 | xorl %eax, %edi # (((c ^ d) & b) ^ d) | ||
219 | leal 0x5A827999(%rbx,%r13), %ebx # e += RCONST + W[n] | ||
220 | addl %edi, %ebx # e += (((c ^ d) & b) ^ d) | ||
221 | movl %ecx, %esi # | ||
222 | roll $5, %esi # rotl32(a,5) | ||
223 | addl %esi, %ebx # e += rotl32(a,5) | ||
224 | rorl $2, %edx # b = rotl32(b,30) | ||
225 | # 14 | ||
226 | # W[n], in %r14 | ||
227 | movl %edx, %edi # c | ||
228 | xorl %ebp, %edi # ^d | ||
229 | andl %ecx, %edi # &b | ||
230 | xorl %ebp, %edi # (((c ^ d) & b) ^ d) | ||
231 | leal 0x5A827999(%rax,%r14), %eax # e += RCONST + W[n] | ||
232 | addl %edi, %eax # e += (((c ^ d) & b) ^ d) | ||
233 | movl %ebx, %esi # | ||
234 | roll $5, %esi # rotl32(a,5) | ||
235 | addl %esi, %eax # e += rotl32(a,5) | ||
236 | rorl $2, %ecx # b = rotl32(b,30) | ||
237 | # 15 | ||
238 | # W[n], in %r15 | ||
239 | movl %ecx, %edi # c | ||
240 | xorl %edx, %edi # ^d | ||
241 | andl %ebx, %edi # &b | ||
242 | xorl %edx, %edi # (((c ^ d) & b) ^ d) | ||
243 | leal 0x5A827999(%rbp,%r15), %ebp # e += RCONST + W[n] | ||
244 | addl %edi, %ebp # e += (((c ^ d) & b) ^ d) | ||
245 | movl %eax, %esi # | ||
246 | roll $5, %esi # rotl32(a,5) | ||
247 | addl %esi, %ebp # e += rotl32(a,5) | ||
248 | rorl $2, %ebx # b = rotl32(b,30) | ||
249 | # 16 | ||
250 | movl %r13d, %esi # W[(n+13) & 15] | ||
251 | xorl %r8d, %esi # ^W[(n+8) & 15] | ||
252 | xorl -32+4*2(%rsp), %esi # ^W[(n+2) & 15] | ||
253 | xorl -32+4*0(%rsp), %esi # ^W[n & 15] | ||
254 | roll %esi # | ||
255 | movl %esi, -32+4*0(%rsp) # store to W[n & 15] | ||
256 | movl %ebx, %edi # c | ||
257 | xorl %ecx, %edi # ^d | ||
258 | andl %eax, %edi # &b | ||
259 | xorl %ecx, %edi # (((c ^ d) & b) ^ d) | ||
260 | leal 0x5A827999(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
261 | addl %edi, %edx # e += (((c ^ d) & b) ^ d) | ||
262 | movl %ebp, %esi # | ||
263 | roll $5, %esi # rotl32(a,5) | ||
264 | addl %esi, %edx # e += rotl32(a,5) | ||
265 | rorl $2, %eax # b = rotl32(b,30) | ||
266 | # 17 | ||
267 | movl %r14d, %esi # W[(n+13) & 15] | ||
268 | xorl %r9d, %esi # ^W[(n+8) & 15] | ||
269 | xorl -32+4*3(%rsp), %esi # ^W[(n+2) & 15] | ||
270 | xorl -32+4*1(%rsp), %esi # ^W[n & 15] | ||
271 | roll %esi # | ||
272 | movl %esi, -32+4*1(%rsp) # store to W[n & 15] | ||
273 | movl %eax, %edi # c | ||
274 | xorl %ebx, %edi # ^d | ||
275 | andl %ebp, %edi # &b | ||
276 | xorl %ebx, %edi # (((c ^ d) & b) ^ d) | ||
277 | leal 0x5A827999(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
278 | addl %edi, %ecx # e += (((c ^ d) & b) ^ d) | ||
279 | movl %edx, %esi # | ||
280 | roll $5, %esi # rotl32(a,5) | ||
281 | addl %esi, %ecx # e += rotl32(a,5) | ||
282 | rorl $2, %ebp # b = rotl32(b,30) | ||
283 | # 18 | ||
284 | movl %r15d, %esi # W[(n+13) & 15] | ||
285 | xorl %r10d, %esi # ^W[(n+8) & 15] | ||
286 | xorl -32+4*4(%rsp), %esi # ^W[(n+2) & 15] | ||
287 | xorl -32+4*2(%rsp), %esi # ^W[n & 15] | ||
288 | roll %esi # | ||
289 | movl %esi, -32+4*2(%rsp) # store to W[n & 15] | ||
290 | movl %ebp, %edi # c | ||
291 | xorl %eax, %edi # ^d | ||
292 | andl %edx, %edi # &b | ||
293 | xorl %eax, %edi # (((c ^ d) & b) ^ d) | ||
294 | leal 0x5A827999(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
295 | addl %edi, %ebx # e += (((c ^ d) & b) ^ d) | ||
296 | movl %ecx, %esi # | ||
297 | roll $5, %esi # rotl32(a,5) | ||
298 | addl %esi, %ebx # e += rotl32(a,5) | ||
299 | rorl $2, %edx # b = rotl32(b,30) | ||
300 | # 19 | ||
301 | movl -32+4*0(%rsp), %esi # W[(n+13) & 15] | ||
302 | xorl %r11d, %esi # ^W[(n+8) & 15] | ||
303 | xorl -32+4*5(%rsp), %esi # ^W[(n+2) & 15] | ||
304 | xorl -32+4*3(%rsp), %esi # ^W[n & 15] | ||
305 | roll %esi # | ||
306 | movl %esi, -32+4*3(%rsp) # store to W[n & 15] | ||
307 | movl %edx, %edi # c | ||
308 | xorl %ebp, %edi # ^d | ||
309 | andl %ecx, %edi # &b | ||
310 | xorl %ebp, %edi # (((c ^ d) & b) ^ d) | ||
311 | leal 0x5A827999(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
312 | addl %edi, %eax # e += (((c ^ d) & b) ^ d) | ||
313 | movl %ebx, %esi # | ||
314 | roll $5, %esi # rotl32(a,5) | ||
315 | addl %esi, %eax # e += rotl32(a,5) | ||
316 | rorl $2, %ecx # b = rotl32(b,30) | ||
317 | # 20 | ||
318 | movl -32+4*1(%rsp), %esi # W[(n+13) & 15] | ||
319 | xorl %r12d, %esi # ^W[(n+8) & 15] | ||
320 | xorl -32+4*6(%rsp), %esi # ^W[(n+2) & 15] | ||
321 | xorl -32+4*4(%rsp), %esi # ^W[n & 15] | ||
322 | roll %esi # | ||
323 | movl %esi, -32+4*4(%rsp) # store to W[n & 15] | ||
324 | movl %ecx, %edi # c | ||
325 | xorl %edx, %edi # ^d | ||
326 | xorl %ebx, %edi # ^b | ||
327 | leal 0x6ED9EBA1(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
328 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
329 | movl %eax, %esi # | ||
330 | roll $5, %esi # rotl32(a,5) | ||
331 | addl %esi, %ebp # e += rotl32(a,5) | ||
332 | rorl $2, %ebx # b = rotl32(b,30) | ||
333 | # 21 | ||
334 | movl -32+4*2(%rsp), %esi # W[(n+13) & 15] | ||
335 | xorl %r13d, %esi # ^W[(n+8) & 15] | ||
336 | xorl -32+4*7(%rsp), %esi # ^W[(n+2) & 15] | ||
337 | xorl -32+4*5(%rsp), %esi # ^W[n & 15] | ||
338 | roll %esi # | ||
339 | movl %esi, -32+4*5(%rsp) # store to W[n & 15] | ||
340 | movl %ebx, %edi # c | ||
341 | xorl %ecx, %edi # ^d | ||
342 | xorl %eax, %edi # ^b | ||
343 | leal 0x6ED9EBA1(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
344 | addl %edi, %edx # e += (c ^ d ^ b) | ||
345 | movl %ebp, %esi # | ||
346 | roll $5, %esi # rotl32(a,5) | ||
347 | addl %esi, %edx # e += rotl32(a,5) | ||
348 | rorl $2, %eax # b = rotl32(b,30) | ||
349 | # 22 | ||
350 | movl -32+4*3(%rsp), %esi # W[(n+13) & 15] | ||
351 | xorl %r14d, %esi # ^W[(n+8) & 15] | ||
352 | xorl %r8d, %esi # ^W[(n+2) & 15] | ||
353 | xorl -32+4*6(%rsp), %esi # ^W[n & 15] | ||
354 | roll %esi # | ||
355 | movl %esi, -32+4*6(%rsp) # store to W[n & 15] | ||
356 | movl %eax, %edi # c | ||
357 | xorl %ebx, %edi # ^d | ||
358 | xorl %ebp, %edi # ^b | ||
359 | leal 0x6ED9EBA1(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
360 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
361 | movl %edx, %esi # | ||
362 | roll $5, %esi # rotl32(a,5) | ||
363 | addl %esi, %ecx # e += rotl32(a,5) | ||
364 | rorl $2, %ebp # b = rotl32(b,30) | ||
365 | # 23 | ||
366 | movl -32+4*4(%rsp), %esi # W[(n+13) & 15] | ||
367 | xorl %r15d, %esi # ^W[(n+8) & 15] | ||
368 | xorl %r9d, %esi # ^W[(n+2) & 15] | ||
369 | xorl -32+4*7(%rsp), %esi # ^W[n & 15] | ||
370 | roll %esi # | ||
371 | movl %esi, -32+4*7(%rsp) # store to W[n & 15] | ||
372 | movl %ebp, %edi # c | ||
373 | xorl %eax, %edi # ^d | ||
374 | xorl %edx, %edi # ^b | ||
375 | leal 0x6ED9EBA1(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
376 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
377 | movl %ecx, %esi # | ||
378 | roll $5, %esi # rotl32(a,5) | ||
379 | addl %esi, %ebx # e += rotl32(a,5) | ||
380 | rorl $2, %edx # b = rotl32(b,30) | ||
381 | # 24 | ||
382 | xorl -32+4*5(%rsp), %r8d # W[n & 15] ^= W[(n+13) & 15] | ||
383 | xorl -32+4*0(%rsp), %r8d # ^W[(n+8) & 15] | ||
384 | xorl %r10d, %r8d # ^W[(n+2) & 15] | ||
385 | roll %r8d # | ||
386 | movl %edx, %edi # c | ||
387 | xorl %ebp, %edi # ^d | ||
388 | xorl %ecx, %edi # ^b | ||
389 | leal 0x6ED9EBA1(%rax,%r8), %eax # e += RCONST + W[n & 15] | ||
390 | addl %edi, %eax # e += (c ^ d ^ b) | ||
391 | movl %ebx, %esi # | ||
392 | roll $5, %esi # rotl32(a,5) | ||
393 | addl %esi, %eax # e += rotl32(a,5) | ||
394 | rorl $2, %ecx # b = rotl32(b,30) | ||
395 | # 25 | ||
396 | xorl -32+4*6(%rsp), %r9d # W[n & 15] ^= W[(n+13) & 15] | ||
397 | xorl -32+4*1(%rsp), %r9d # ^W[(n+8) & 15] | ||
398 | xorl %r11d, %r9d # ^W[(n+2) & 15] | ||
399 | roll %r9d # | ||
400 | movl %ecx, %edi # c | ||
401 | xorl %edx, %edi # ^d | ||
402 | xorl %ebx, %edi # ^b | ||
403 | leal 0x6ED9EBA1(%rbp,%r9), %ebp # e += RCONST + W[n & 15] | ||
404 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
405 | movl %eax, %esi # | ||
406 | roll $5, %esi # rotl32(a,5) | ||
407 | addl %esi, %ebp # e += rotl32(a,5) | ||
408 | rorl $2, %ebx # b = rotl32(b,30) | ||
409 | # 26 | ||
410 | xorl -32+4*7(%rsp), %r10d # W[n & 15] ^= W[(n+13) & 15] | ||
411 | xorl -32+4*2(%rsp), %r10d # ^W[(n+8) & 15] | ||
412 | xorl %r12d, %r10d # ^W[(n+2) & 15] | ||
413 | roll %r10d # | ||
414 | movl %ebx, %edi # c | ||
415 | xorl %ecx, %edi # ^d | ||
416 | xorl %eax, %edi # ^b | ||
417 | leal 0x6ED9EBA1(%rdx,%r10), %edx # e += RCONST + W[n & 15] | ||
418 | addl %edi, %edx # e += (c ^ d ^ b) | ||
419 | movl %ebp, %esi # | ||
420 | roll $5, %esi # rotl32(a,5) | ||
421 | addl %esi, %edx # e += rotl32(a,5) | ||
422 | rorl $2, %eax # b = rotl32(b,30) | ||
423 | # 27 | ||
424 | xorl %r8d, %r11d # W[n & 15] ^= W[(n+13) & 15] | ||
425 | xorl -32+4*3(%rsp), %r11d # ^W[(n+8) & 15] | ||
426 | xorl %r13d, %r11d # ^W[(n+2) & 15] | ||
427 | roll %r11d # | ||
428 | movl %eax, %edi # c | ||
429 | xorl %ebx, %edi # ^d | ||
430 | xorl %ebp, %edi # ^b | ||
431 | leal 0x6ED9EBA1(%rcx,%r11), %ecx # e += RCONST + W[n & 15] | ||
432 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
433 | movl %edx, %esi # | ||
434 | roll $5, %esi # rotl32(a,5) | ||
435 | addl %esi, %ecx # e += rotl32(a,5) | ||
436 | rorl $2, %ebp # b = rotl32(b,30) | ||
437 | # 28 | ||
438 | xorl %r9d, %r12d # W[n & 15] ^= W[(n+13) & 15] | ||
439 | xorl -32+4*4(%rsp), %r12d # ^W[(n+8) & 15] | ||
440 | xorl %r14d, %r12d # ^W[(n+2) & 15] | ||
441 | roll %r12d # | ||
442 | movl %ebp, %edi # c | ||
443 | xorl %eax, %edi # ^d | ||
444 | xorl %edx, %edi # ^b | ||
445 | leal 0x6ED9EBA1(%rbx,%r12), %ebx # e += RCONST + W[n & 15] | ||
446 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
447 | movl %ecx, %esi # | ||
448 | roll $5, %esi # rotl32(a,5) | ||
449 | addl %esi, %ebx # e += rotl32(a,5) | ||
450 | rorl $2, %edx # b = rotl32(b,30) | ||
451 | # 29 | ||
452 | xorl %r10d, %r13d # W[n & 15] ^= W[(n+13) & 15] | ||
453 | xorl -32+4*5(%rsp), %r13d # ^W[(n+8) & 15] | ||
454 | xorl %r15d, %r13d # ^W[(n+2) & 15] | ||
455 | roll %r13d # | ||
456 | movl %edx, %edi # c | ||
457 | xorl %ebp, %edi # ^d | ||
458 | xorl %ecx, %edi # ^b | ||
459 | leal 0x6ED9EBA1(%rax,%r13), %eax # e += RCONST + W[n & 15] | ||
460 | addl %edi, %eax # e += (c ^ d ^ b) | ||
461 | movl %ebx, %esi # | ||
462 | roll $5, %esi # rotl32(a,5) | ||
463 | addl %esi, %eax # e += rotl32(a,5) | ||
464 | rorl $2, %ecx # b = rotl32(b,30) | ||
465 | # 30 | ||
466 | xorl %r11d, %r14d # W[n & 15] ^= W[(n+13) & 15] | ||
467 | xorl -32+4*6(%rsp), %r14d # ^W[(n+8) & 15] | ||
468 | xorl -32+4*0(%rsp), %r14d # ^W[(n+2) & 15] | ||
469 | roll %r14d # | ||
470 | movl %ecx, %edi # c | ||
471 | xorl %edx, %edi # ^d | ||
472 | xorl %ebx, %edi # ^b | ||
473 | leal 0x6ED9EBA1(%rbp,%r14), %ebp # e += RCONST + W[n & 15] | ||
474 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
475 | movl %eax, %esi # | ||
476 | roll $5, %esi # rotl32(a,5) | ||
477 | addl %esi, %ebp # e += rotl32(a,5) | ||
478 | rorl $2, %ebx # b = rotl32(b,30) | ||
479 | # 31 | ||
480 | xorl %r12d, %r15d # W[n & 15] ^= W[(n+13) & 15] | ||
481 | xorl -32+4*7(%rsp), %r15d # ^W[(n+8) & 15] | ||
482 | xorl -32+4*1(%rsp), %r15d # ^W[(n+2) & 15] | ||
483 | roll %r15d # | ||
484 | movl %ebx, %edi # c | ||
485 | xorl %ecx, %edi # ^d | ||
486 | xorl %eax, %edi # ^b | ||
487 | leal 0x6ED9EBA1(%rdx,%r15), %edx # e += RCONST + W[n & 15] | ||
488 | addl %edi, %edx # e += (c ^ d ^ b) | ||
489 | movl %ebp, %esi # | ||
490 | roll $5, %esi # rotl32(a,5) | ||
491 | addl %esi, %edx # e += rotl32(a,5) | ||
492 | rorl $2, %eax # b = rotl32(b,30) | ||
493 | # 32 | ||
494 | movl %r13d, %esi # W[(n+13) & 15] | ||
495 | xorl %r8d, %esi # ^W[(n+8) & 15] | ||
496 | xorl -32+4*2(%rsp), %esi # ^W[(n+2) & 15] | ||
497 | xorl -32+4*0(%rsp), %esi # ^W[n & 15] | ||
498 | roll %esi # | ||
499 | movl %esi, -32+4*0(%rsp) # store to W[n & 15] | ||
500 | movl %eax, %edi # c | ||
501 | xorl %ebx, %edi # ^d | ||
502 | xorl %ebp, %edi # ^b | ||
503 | leal 0x6ED9EBA1(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
504 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
505 | movl %edx, %esi # | ||
506 | roll $5, %esi # rotl32(a,5) | ||
507 | addl %esi, %ecx # e += rotl32(a,5) | ||
508 | rorl $2, %ebp # b = rotl32(b,30) | ||
509 | # 33 | ||
510 | movl %r14d, %esi # W[(n+13) & 15] | ||
511 | xorl %r9d, %esi # ^W[(n+8) & 15] | ||
512 | xorl -32+4*3(%rsp), %esi # ^W[(n+2) & 15] | ||
513 | xorl -32+4*1(%rsp), %esi # ^W[n & 15] | ||
514 | roll %esi # | ||
515 | movl %esi, -32+4*1(%rsp) # store to W[n & 15] | ||
516 | movl %ebp, %edi # c | ||
517 | xorl %eax, %edi # ^d | ||
518 | xorl %edx, %edi # ^b | ||
519 | leal 0x6ED9EBA1(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
520 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
521 | movl %ecx, %esi # | ||
522 | roll $5, %esi # rotl32(a,5) | ||
523 | addl %esi, %ebx # e += rotl32(a,5) | ||
524 | rorl $2, %edx # b = rotl32(b,30) | ||
525 | # 34 | ||
526 | movl %r15d, %esi # W[(n+13) & 15] | ||
527 | xorl %r10d, %esi # ^W[(n+8) & 15] | ||
528 | xorl -32+4*4(%rsp), %esi # ^W[(n+2) & 15] | ||
529 | xorl -32+4*2(%rsp), %esi # ^W[n & 15] | ||
530 | roll %esi # | ||
531 | movl %esi, -32+4*2(%rsp) # store to W[n & 15] | ||
532 | movl %edx, %edi # c | ||
533 | xorl %ebp, %edi # ^d | ||
534 | xorl %ecx, %edi # ^b | ||
535 | leal 0x6ED9EBA1(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
536 | addl %edi, %eax # e += (c ^ d ^ b) | ||
537 | movl %ebx, %esi # | ||
538 | roll $5, %esi # rotl32(a,5) | ||
539 | addl %esi, %eax # e += rotl32(a,5) | ||
540 | rorl $2, %ecx # b = rotl32(b,30) | ||
541 | # 35 | ||
542 | movl -32+4*0(%rsp), %esi # W[(n+13) & 15] | ||
543 | xorl %r11d, %esi # ^W[(n+8) & 15] | ||
544 | xorl -32+4*5(%rsp), %esi # ^W[(n+2) & 15] | ||
545 | xorl -32+4*3(%rsp), %esi # ^W[n & 15] | ||
546 | roll %esi # | ||
547 | movl %esi, -32+4*3(%rsp) # store to W[n & 15] | ||
548 | movl %ecx, %edi # c | ||
549 | xorl %edx, %edi # ^d | ||
550 | xorl %ebx, %edi # ^b | ||
551 | leal 0x6ED9EBA1(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
552 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
553 | movl %eax, %esi # | ||
554 | roll $5, %esi # rotl32(a,5) | ||
555 | addl %esi, %ebp # e += rotl32(a,5) | ||
556 | rorl $2, %ebx # b = rotl32(b,30) | ||
557 | # 36 | ||
558 | movl -32+4*1(%rsp), %esi # W[(n+13) & 15] | ||
559 | xorl %r12d, %esi # ^W[(n+8) & 15] | ||
560 | xorl -32+4*6(%rsp), %esi # ^W[(n+2) & 15] | ||
561 | xorl -32+4*4(%rsp), %esi # ^W[n & 15] | ||
562 | roll %esi # | ||
563 | movl %esi, -32+4*4(%rsp) # store to W[n & 15] | ||
564 | movl %ebx, %edi # c | ||
565 | xorl %ecx, %edi # ^d | ||
566 | xorl %eax, %edi # ^b | ||
567 | leal 0x6ED9EBA1(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
568 | addl %edi, %edx # e += (c ^ d ^ b) | ||
569 | movl %ebp, %esi # | ||
570 | roll $5, %esi # rotl32(a,5) | ||
571 | addl %esi, %edx # e += rotl32(a,5) | ||
572 | rorl $2, %eax # b = rotl32(b,30) | ||
573 | # 37 | ||
574 | movl -32+4*2(%rsp), %esi # W[(n+13) & 15] | ||
575 | xorl %r13d, %esi # ^W[(n+8) & 15] | ||
576 | xorl -32+4*7(%rsp), %esi # ^W[(n+2) & 15] | ||
577 | xorl -32+4*5(%rsp), %esi # ^W[n & 15] | ||
578 | roll %esi # | ||
579 | movl %esi, -32+4*5(%rsp) # store to W[n & 15] | ||
580 | movl %eax, %edi # c | ||
581 | xorl %ebx, %edi # ^d | ||
582 | xorl %ebp, %edi # ^b | ||
583 | leal 0x6ED9EBA1(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
584 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
585 | movl %edx, %esi # | ||
586 | roll $5, %esi # rotl32(a,5) | ||
587 | addl %esi, %ecx # e += rotl32(a,5) | ||
588 | rorl $2, %ebp # b = rotl32(b,30) | ||
589 | # 38 | ||
590 | movl -32+4*3(%rsp), %esi # W[(n+13) & 15] | ||
591 | xorl %r14d, %esi # ^W[(n+8) & 15] | ||
592 | xorl %r8d, %esi # ^W[(n+2) & 15] | ||
593 | xorl -32+4*6(%rsp), %esi # ^W[n & 15] | ||
594 | roll %esi # | ||
595 | movl %esi, -32+4*6(%rsp) # store to W[n & 15] | ||
596 | movl %ebp, %edi # c | ||
597 | xorl %eax, %edi # ^d | ||
598 | xorl %edx, %edi # ^b | ||
599 | leal 0x6ED9EBA1(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
600 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
601 | movl %ecx, %esi # | ||
602 | roll $5, %esi # rotl32(a,5) | ||
603 | addl %esi, %ebx # e += rotl32(a,5) | ||
604 | rorl $2, %edx # b = rotl32(b,30) | ||
605 | # 39 | ||
606 | movl -32+4*4(%rsp), %esi # W[(n+13) & 15] | ||
607 | xorl %r15d, %esi # ^W[(n+8) & 15] | ||
608 | xorl %r9d, %esi # ^W[(n+2) & 15] | ||
609 | xorl -32+4*7(%rsp), %esi # ^W[n & 15] | ||
610 | roll %esi # | ||
611 | movl %esi, -32+4*7(%rsp) # store to W[n & 15] | ||
612 | movl %edx, %edi # c | ||
613 | xorl %ebp, %edi # ^d | ||
614 | xorl %ecx, %edi # ^b | ||
615 | leal 0x6ED9EBA1(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
616 | addl %edi, %eax # e += (c ^ d ^ b) | ||
617 | movl %ebx, %esi # | ||
618 | roll $5, %esi # rotl32(a,5) | ||
619 | addl %esi, %eax # e += rotl32(a,5) | ||
620 | rorl $2, %ecx # b = rotl32(b,30) | ||
621 | # 40 | ||
622 | movl %ebx, %edi # di: b | ||
623 | movl %ebx, %esi # si: b | ||
624 | orl %ecx, %edi # di: b | c | ||
625 | andl %ecx, %esi # si: b & c | ||
626 | andl %edx, %edi # di: (b | c) & d | ||
627 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
628 | xorl -32+4*5(%rsp), %r8d # W[n & 15] ^= W[(n+13) & 15] | ||
629 | xorl -32+4*0(%rsp), %r8d # ^W[(n+8) & 15] | ||
630 | xorl %r10d, %r8d # ^W[(n+2) & 15] | ||
631 | roll %r8d # | ||
632 | addl %edi, %ebp # += ((b | c) & d) | (b & c) | ||
633 | leal -0x70E44324(%rbp,%r8), %ebp # e += RCONST + W[n & 15] | ||
634 | movl %eax, %esi # | ||
635 | roll $5, %esi # rotl32(a,5) | ||
636 | addl %esi, %ebp # e += rotl32(a,5) | ||
637 | rorl $2, %ebx # b = rotl32(b,30) | ||
638 | # 41 | ||
639 | movl %eax, %edi # di: b | ||
640 | movl %eax, %esi # si: b | ||
641 | orl %ebx, %edi # di: b | c | ||
642 | andl %ebx, %esi # si: b & c | ||
643 | andl %ecx, %edi # di: (b | c) & d | ||
644 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
645 | xorl -32+4*6(%rsp), %r9d # W[n & 15] ^= W[(n+13) & 15] | ||
646 | xorl -32+4*1(%rsp), %r9d # ^W[(n+8) & 15] | ||
647 | xorl %r11d, %r9d # ^W[(n+2) & 15] | ||
648 | roll %r9d # | ||
649 | addl %edi, %edx # += ((b | c) & d) | (b & c) | ||
650 | leal -0x70E44324(%rdx,%r9), %edx # e += RCONST + W[n & 15] | ||
651 | movl %ebp, %esi # | ||
652 | roll $5, %esi # rotl32(a,5) | ||
653 | addl %esi, %edx # e += rotl32(a,5) | ||
654 | rorl $2, %eax # b = rotl32(b,30) | ||
655 | # 42 | ||
656 | movl %ebp, %edi # di: b | ||
657 | movl %ebp, %esi # si: b | ||
658 | orl %eax, %edi # di: b | c | ||
659 | andl %eax, %esi # si: b & c | ||
660 | andl %ebx, %edi # di: (b | c) & d | ||
661 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
662 | xorl -32+4*7(%rsp), %r10d # W[n & 15] ^= W[(n+13) & 15] | ||
663 | xorl -32+4*2(%rsp), %r10d # ^W[(n+8) & 15] | ||
664 | xorl %r12d, %r10d # ^W[(n+2) & 15] | ||
665 | roll %r10d # | ||
666 | addl %edi, %ecx # += ((b | c) & d) | (b & c) | ||
667 | leal -0x70E44324(%rcx,%r10), %ecx # e += RCONST + W[n & 15] | ||
668 | movl %edx, %esi # | ||
669 | roll $5, %esi # rotl32(a,5) | ||
670 | addl %esi, %ecx # e += rotl32(a,5) | ||
671 | rorl $2, %ebp # b = rotl32(b,30) | ||
672 | # 43 | ||
673 | movl %edx, %edi # di: b | ||
674 | movl %edx, %esi # si: b | ||
675 | orl %ebp, %edi # di: b | c | ||
676 | andl %ebp, %esi # si: b & c | ||
677 | andl %eax, %edi # di: (b | c) & d | ||
678 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
679 | xorl %r8d, %r11d # W[n & 15] ^= W[(n+13) & 15] | ||
680 | xorl -32+4*3(%rsp), %r11d # ^W[(n+8) & 15] | ||
681 | xorl %r13d, %r11d # ^W[(n+2) & 15] | ||
682 | roll %r11d # | ||
683 | addl %edi, %ebx # += ((b | c) & d) | (b & c) | ||
684 | leal -0x70E44324(%rbx,%r11), %ebx # e += RCONST + W[n & 15] | ||
685 | movl %ecx, %esi # | ||
686 | roll $5, %esi # rotl32(a,5) | ||
687 | addl %esi, %ebx # e += rotl32(a,5) | ||
688 | rorl $2, %edx # b = rotl32(b,30) | ||
689 | # 44 | ||
690 | movl %ecx, %edi # di: b | ||
691 | movl %ecx, %esi # si: b | ||
692 | orl %edx, %edi # di: b | c | ||
693 | andl %edx, %esi # si: b & c | ||
694 | andl %ebp, %edi # di: (b | c) & d | ||
695 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
696 | xorl %r9d, %r12d # W[n & 15] ^= W[(n+13) & 15] | ||
697 | xorl -32+4*4(%rsp), %r12d # ^W[(n+8) & 15] | ||
698 | xorl %r14d, %r12d # ^W[(n+2) & 15] | ||
699 | roll %r12d # | ||
700 | addl %edi, %eax # += ((b | c) & d) | (b & c) | ||
701 | leal -0x70E44324(%rax,%r12), %eax # e += RCONST + W[n & 15] | ||
702 | movl %ebx, %esi # | ||
703 | roll $5, %esi # rotl32(a,5) | ||
704 | addl %esi, %eax # e += rotl32(a,5) | ||
705 | rorl $2, %ecx # b = rotl32(b,30) | ||
706 | # 45 | ||
707 | movl %ebx, %edi # di: b | ||
708 | movl %ebx, %esi # si: b | ||
709 | orl %ecx, %edi # di: b | c | ||
710 | andl %ecx, %esi # si: b & c | ||
711 | andl %edx, %edi # di: (b | c) & d | ||
712 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
713 | xorl %r10d, %r13d # W[n & 15] ^= W[(n+13) & 15] | ||
714 | xorl -32+4*5(%rsp), %r13d # ^W[(n+8) & 15] | ||
715 | xorl %r15d, %r13d # ^W[(n+2) & 15] | ||
716 | roll %r13d # | ||
717 | addl %edi, %ebp # += ((b | c) & d) | (b & c) | ||
718 | leal -0x70E44324(%rbp,%r13), %ebp # e += RCONST + W[n & 15] | ||
719 | movl %eax, %esi # | ||
720 | roll $5, %esi # rotl32(a,5) | ||
721 | addl %esi, %ebp # e += rotl32(a,5) | ||
722 | rorl $2, %ebx # b = rotl32(b,30) | ||
723 | # 46 | ||
724 | movl %eax, %edi # di: b | ||
725 | movl %eax, %esi # si: b | ||
726 | orl %ebx, %edi # di: b | c | ||
727 | andl %ebx, %esi # si: b & c | ||
728 | andl %ecx, %edi # di: (b | c) & d | ||
729 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
730 | xorl %r11d, %r14d # W[n & 15] ^= W[(n+13) & 15] | ||
731 | xorl -32+4*6(%rsp), %r14d # ^W[(n+8) & 15] | ||
732 | xorl -32+4*0(%rsp), %r14d # ^W[(n+2) & 15] | ||
733 | roll %r14d # | ||
734 | addl %edi, %edx # += ((b | c) & d) | (b & c) | ||
735 | leal -0x70E44324(%rdx,%r14), %edx # e += RCONST + W[n & 15] | ||
736 | movl %ebp, %esi # | ||
737 | roll $5, %esi # rotl32(a,5) | ||
738 | addl %esi, %edx # e += rotl32(a,5) | ||
739 | rorl $2, %eax # b = rotl32(b,30) | ||
740 | # 47 | ||
741 | movl %ebp, %edi # di: b | ||
742 | movl %ebp, %esi # si: b | ||
743 | orl %eax, %edi # di: b | c | ||
744 | andl %eax, %esi # si: b & c | ||
745 | andl %ebx, %edi # di: (b | c) & d | ||
746 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
747 | xorl %r12d, %r15d # W[n & 15] ^= W[(n+13) & 15] | ||
748 | xorl -32+4*7(%rsp), %r15d # ^W[(n+8) & 15] | ||
749 | xorl -32+4*1(%rsp), %r15d # ^W[(n+2) & 15] | ||
750 | roll %r15d # | ||
751 | addl %edi, %ecx # += ((b | c) & d) | (b & c) | ||
752 | leal -0x70E44324(%rcx,%r15), %ecx # e += RCONST + W[n & 15] | ||
753 | movl %edx, %esi # | ||
754 | roll $5, %esi # rotl32(a,5) | ||
755 | addl %esi, %ecx # e += rotl32(a,5) | ||
756 | rorl $2, %ebp # b = rotl32(b,30) | ||
757 | # 48 | ||
758 | movl %edx, %edi # di: b | ||
759 | movl %edx, %esi # si: b | ||
760 | orl %ebp, %edi # di: b | c | ||
761 | andl %ebp, %esi # si: b & c | ||
762 | andl %eax, %edi # di: (b | c) & d | ||
763 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
764 | movl %r13d, %esi # W[(n+13) & 15] | ||
765 | xorl %r8d, %esi # ^W[(n+8) & 15] | ||
766 | xorl -32+4*2(%rsp), %esi # ^W[(n+2) & 15] | ||
767 | xorl -32+4*0(%rsp), %esi # ^W[n & 15] | ||
768 | roll %esi # | ||
769 | movl %esi, -32+4*0(%rsp) # store to W[n & 15] | ||
770 | addl %edi, %ebx # += ((b | c) & d) | (b & c) | ||
771 | leal -0x70E44324(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
772 | movl %ecx, %esi # | ||
773 | roll $5, %esi # rotl32(a,5) | ||
774 | addl %esi, %ebx # e += rotl32(a,5) | ||
775 | rorl $2, %edx # b = rotl32(b,30) | ||
776 | # 49 | ||
777 | movl %ecx, %edi # di: b | ||
778 | movl %ecx, %esi # si: b | ||
779 | orl %edx, %edi # di: b | c | ||
780 | andl %edx, %esi # si: b & c | ||
781 | andl %ebp, %edi # di: (b | c) & d | ||
782 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
783 | movl %r14d, %esi # W[(n+13) & 15] | ||
784 | xorl %r9d, %esi # ^W[(n+8) & 15] | ||
785 | xorl -32+4*3(%rsp), %esi # ^W[(n+2) & 15] | ||
786 | xorl -32+4*1(%rsp), %esi # ^W[n & 15] | ||
787 | roll %esi # | ||
788 | movl %esi, -32+4*1(%rsp) # store to W[n & 15] | ||
789 | addl %edi, %eax # += ((b | c) & d) | (b & c) | ||
790 | leal -0x70E44324(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
791 | movl %ebx, %esi # | ||
792 | roll $5, %esi # rotl32(a,5) | ||
793 | addl %esi, %eax # e += rotl32(a,5) | ||
794 | rorl $2, %ecx # b = rotl32(b,30) | ||
795 | # 50 | ||
796 | movl %ebx, %edi # di: b | ||
797 | movl %ebx, %esi # si: b | ||
798 | orl %ecx, %edi # di: b | c | ||
799 | andl %ecx, %esi # si: b & c | ||
800 | andl %edx, %edi # di: (b | c) & d | ||
801 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
802 | movl %r15d, %esi # W[(n+13) & 15] | ||
803 | xorl %r10d, %esi # ^W[(n+8) & 15] | ||
804 | xorl -32+4*4(%rsp), %esi # ^W[(n+2) & 15] | ||
805 | xorl -32+4*2(%rsp), %esi # ^W[n & 15] | ||
806 | roll %esi # | ||
807 | movl %esi, -32+4*2(%rsp) # store to W[n & 15] | ||
808 | addl %edi, %ebp # += ((b | c) & d) | (b & c) | ||
809 | leal -0x70E44324(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
810 | movl %eax, %esi # | ||
811 | roll $5, %esi # rotl32(a,5) | ||
812 | addl %esi, %ebp # e += rotl32(a,5) | ||
813 | rorl $2, %ebx # b = rotl32(b,30) | ||
814 | # 51 | ||
815 | movl %eax, %edi # di: b | ||
816 | movl %eax, %esi # si: b | ||
817 | orl %ebx, %edi # di: b | c | ||
818 | andl %ebx, %esi # si: b & c | ||
819 | andl %ecx, %edi # di: (b | c) & d | ||
820 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
821 | movl -32+4*0(%rsp), %esi # W[(n+13) & 15] | ||
822 | xorl %r11d, %esi # ^W[(n+8) & 15] | ||
823 | xorl -32+4*5(%rsp), %esi # ^W[(n+2) & 15] | ||
824 | xorl -32+4*3(%rsp), %esi # ^W[n & 15] | ||
825 | roll %esi # | ||
826 | movl %esi, -32+4*3(%rsp) # store to W[n & 15] | ||
827 | addl %edi, %edx # += ((b | c) & d) | (b & c) | ||
828 | leal -0x70E44324(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
829 | movl %ebp, %esi # | ||
830 | roll $5, %esi # rotl32(a,5) | ||
831 | addl %esi, %edx # e += rotl32(a,5) | ||
832 | rorl $2, %eax # b = rotl32(b,30) | ||
833 | # 52 | ||
834 | movl %ebp, %edi # di: b | ||
835 | movl %ebp, %esi # si: b | ||
836 | orl %eax, %edi # di: b | c | ||
837 | andl %eax, %esi # si: b & c | ||
838 | andl %ebx, %edi # di: (b | c) & d | ||
839 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
840 | movl -32+4*1(%rsp), %esi # W[(n+13) & 15] | ||
841 | xorl %r12d, %esi # ^W[(n+8) & 15] | ||
842 | xorl -32+4*6(%rsp), %esi # ^W[(n+2) & 15] | ||
843 | xorl -32+4*4(%rsp), %esi # ^W[n & 15] | ||
844 | roll %esi # | ||
845 | movl %esi, -32+4*4(%rsp) # store to W[n & 15] | ||
846 | addl %edi, %ecx # += ((b | c) & d) | (b & c) | ||
847 | leal -0x70E44324(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
848 | movl %edx, %esi # | ||
849 | roll $5, %esi # rotl32(a,5) | ||
850 | addl %esi, %ecx # e += rotl32(a,5) | ||
851 | rorl $2, %ebp # b = rotl32(b,30) | ||
852 | # 53 | ||
853 | movl %edx, %edi # di: b | ||
854 | movl %edx, %esi # si: b | ||
855 | orl %ebp, %edi # di: b | c | ||
856 | andl %ebp, %esi # si: b & c | ||
857 | andl %eax, %edi # di: (b | c) & d | ||
858 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
859 | movl -32+4*2(%rsp), %esi # W[(n+13) & 15] | ||
860 | xorl %r13d, %esi # ^W[(n+8) & 15] | ||
861 | xorl -32+4*7(%rsp), %esi # ^W[(n+2) & 15] | ||
862 | xorl -32+4*5(%rsp), %esi # ^W[n & 15] | ||
863 | roll %esi # | ||
864 | movl %esi, -32+4*5(%rsp) # store to W[n & 15] | ||
865 | addl %edi, %ebx # += ((b | c) & d) | (b & c) | ||
866 | leal -0x70E44324(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
867 | movl %ecx, %esi # | ||
868 | roll $5, %esi # rotl32(a,5) | ||
869 | addl %esi, %ebx # e += rotl32(a,5) | ||
870 | rorl $2, %edx # b = rotl32(b,30) | ||
871 | # 54 | ||
872 | movl %ecx, %edi # di: b | ||
873 | movl %ecx, %esi # si: b | ||
874 | orl %edx, %edi # di: b | c | ||
875 | andl %edx, %esi # si: b & c | ||
876 | andl %ebp, %edi # di: (b | c) & d | ||
877 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
878 | movl -32+4*3(%rsp), %esi # W[(n+13) & 15] | ||
879 | xorl %r14d, %esi # ^W[(n+8) & 15] | ||
880 | xorl %r8d, %esi # ^W[(n+2) & 15] | ||
881 | xorl -32+4*6(%rsp), %esi # ^W[n & 15] | ||
882 | roll %esi # | ||
883 | movl %esi, -32+4*6(%rsp) # store to W[n & 15] | ||
884 | addl %edi, %eax # += ((b | c) & d) | (b & c) | ||
885 | leal -0x70E44324(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
886 | movl %ebx, %esi # | ||
887 | roll $5, %esi # rotl32(a,5) | ||
888 | addl %esi, %eax # e += rotl32(a,5) | ||
889 | rorl $2, %ecx # b = rotl32(b,30) | ||
890 | # 55 | ||
891 | movl %ebx, %edi # di: b | ||
892 | movl %ebx, %esi # si: b | ||
893 | orl %ecx, %edi # di: b | c | ||
894 | andl %ecx, %esi # si: b & c | ||
895 | andl %edx, %edi # di: (b | c) & d | ||
896 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
897 | movl -32+4*4(%rsp), %esi # W[(n+13) & 15] | ||
898 | xorl %r15d, %esi # ^W[(n+8) & 15] | ||
899 | xorl %r9d, %esi # ^W[(n+2) & 15] | ||
900 | xorl -32+4*7(%rsp), %esi # ^W[n & 15] | ||
901 | roll %esi # | ||
902 | movl %esi, -32+4*7(%rsp) # store to W[n & 15] | ||
903 | addl %edi, %ebp # += ((b | c) & d) | (b & c) | ||
904 | leal -0x70E44324(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
905 | movl %eax, %esi # | ||
906 | roll $5, %esi # rotl32(a,5) | ||
907 | addl %esi, %ebp # e += rotl32(a,5) | ||
908 | rorl $2, %ebx # b = rotl32(b,30) | ||
909 | # 56 | ||
910 | movl %eax, %edi # di: b | ||
911 | movl %eax, %esi # si: b | ||
912 | orl %ebx, %edi # di: b | c | ||
913 | andl %ebx, %esi # si: b & c | ||
914 | andl %ecx, %edi # di: (b | c) & d | ||
915 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
916 | xorl -32+4*5(%rsp), %r8d # W[n & 15] ^= W[(n+13) & 15] | ||
917 | xorl -32+4*0(%rsp), %r8d # ^W[(n+8) & 15] | ||
918 | xorl %r10d, %r8d # ^W[(n+2) & 15] | ||
919 | roll %r8d # | ||
920 | addl %edi, %edx # += ((b | c) & d) | (b & c) | ||
921 | leal -0x70E44324(%rdx,%r8), %edx # e += RCONST + W[n & 15] | ||
922 | movl %ebp, %esi # | ||
923 | roll $5, %esi # rotl32(a,5) | ||
924 | addl %esi, %edx # e += rotl32(a,5) | ||
925 | rorl $2, %eax # b = rotl32(b,30) | ||
926 | # 57 | ||
927 | movl %ebp, %edi # di: b | ||
928 | movl %ebp, %esi # si: b | ||
929 | orl %eax, %edi # di: b | c | ||
930 | andl %eax, %esi # si: b & c | ||
931 | andl %ebx, %edi # di: (b | c) & d | ||
932 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
933 | xorl -32+4*6(%rsp), %r9d # W[n & 15] ^= W[(n+13) & 15] | ||
934 | xorl -32+4*1(%rsp), %r9d # ^W[(n+8) & 15] | ||
935 | xorl %r11d, %r9d # ^W[(n+2) & 15] | ||
936 | roll %r9d # | ||
937 | addl %edi, %ecx # += ((b | c) & d) | (b & c) | ||
938 | leal -0x70E44324(%rcx,%r9), %ecx # e += RCONST + W[n & 15] | ||
939 | movl %edx, %esi # | ||
940 | roll $5, %esi # rotl32(a,5) | ||
941 | addl %esi, %ecx # e += rotl32(a,5) | ||
942 | rorl $2, %ebp # b = rotl32(b,30) | ||
943 | # 58 | ||
944 | movl %edx, %edi # di: b | ||
945 | movl %edx, %esi # si: b | ||
946 | orl %ebp, %edi # di: b | c | ||
947 | andl %ebp, %esi # si: b & c | ||
948 | andl %eax, %edi # di: (b | c) & d | ||
949 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
950 | xorl -32+4*7(%rsp), %r10d # W[n & 15] ^= W[(n+13) & 15] | ||
951 | xorl -32+4*2(%rsp), %r10d # ^W[(n+8) & 15] | ||
952 | xorl %r12d, %r10d # ^W[(n+2) & 15] | ||
953 | roll %r10d # | ||
954 | addl %edi, %ebx # += ((b | c) & d) | (b & c) | ||
955 | leal -0x70E44324(%rbx,%r10), %ebx # e += RCONST + W[n & 15] | ||
956 | movl %ecx, %esi # | ||
957 | roll $5, %esi # rotl32(a,5) | ||
958 | addl %esi, %ebx # e += rotl32(a,5) | ||
959 | rorl $2, %edx # b = rotl32(b,30) | ||
960 | # 59 | ||
961 | movl %ecx, %edi # di: b | ||
962 | movl %ecx, %esi # si: b | ||
963 | orl %edx, %edi # di: b | c | ||
964 | andl %edx, %esi # si: b & c | ||
965 | andl %ebp, %edi # di: (b | c) & d | ||
966 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
967 | xorl %r8d, %r11d # W[n & 15] ^= W[(n+13) & 15] | ||
968 | xorl -32+4*3(%rsp), %r11d # ^W[(n+8) & 15] | ||
969 | xorl %r13d, %r11d # ^W[(n+2) & 15] | ||
970 | roll %r11d # | ||
971 | addl %edi, %eax # += ((b | c) & d) | (b & c) | ||
972 | leal -0x70E44324(%rax,%r11), %eax # e += RCONST + W[n & 15] | ||
973 | movl %ebx, %esi # | ||
974 | roll $5, %esi # rotl32(a,5) | ||
975 | addl %esi, %eax # e += rotl32(a,5) | ||
976 | rorl $2, %ecx # b = rotl32(b,30) | ||
977 | # 60 | ||
978 | xorl %r9d, %r12d # W[n & 15] ^= W[(n+13) & 15] | ||
979 | xorl -32+4*4(%rsp), %r12d # ^W[(n+8) & 15] | ||
980 | xorl %r14d, %r12d # ^W[(n+2) & 15] | ||
981 | roll %r12d # | ||
982 | movl %ecx, %edi # c | ||
983 | xorl %edx, %edi # ^d | ||
984 | xorl %ebx, %edi # ^b | ||
985 | leal -0x359D3E2A(%rbp,%r12), %ebp # e += RCONST + W[n & 15] | ||
986 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
987 | movl %eax, %esi # | ||
988 | roll $5, %esi # rotl32(a,5) | ||
989 | addl %esi, %ebp # e += rotl32(a,5) | ||
990 | rorl $2, %ebx # b = rotl32(b,30) | ||
991 | # 61 | ||
992 | xorl %r10d, %r13d # W[n & 15] ^= W[(n+13) & 15] | ||
993 | xorl -32+4*5(%rsp), %r13d # ^W[(n+8) & 15] | ||
994 | xorl %r15d, %r13d # ^W[(n+2) & 15] | ||
995 | roll %r13d # | ||
996 | movl %ebx, %edi # c | ||
997 | xorl %ecx, %edi # ^d | ||
998 | xorl %eax, %edi # ^b | ||
999 | leal -0x359D3E2A(%rdx,%r13), %edx # e += RCONST + W[n & 15] | ||
1000 | addl %edi, %edx # e += (c ^ d ^ b) | ||
1001 | movl %ebp, %esi # | ||
1002 | roll $5, %esi # rotl32(a,5) | ||
1003 | addl %esi, %edx # e += rotl32(a,5) | ||
1004 | rorl $2, %eax # b = rotl32(b,30) | ||
1005 | # 62 | ||
1006 | xorl %r11d, %r14d # W[n & 15] ^= W[(n+13) & 15] | ||
1007 | xorl -32+4*6(%rsp), %r14d # ^W[(n+8) & 15] | ||
1008 | xorl -32+4*0(%rsp), %r14d # ^W[(n+2) & 15] | ||
1009 | roll %r14d # | ||
1010 | movl %eax, %edi # c | ||
1011 | xorl %ebx, %edi # ^d | ||
1012 | xorl %ebp, %edi # ^b | ||
1013 | leal -0x359D3E2A(%rcx,%r14), %ecx # e += RCONST + W[n & 15] | ||
1014 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
1015 | movl %edx, %esi # | ||
1016 | roll $5, %esi # rotl32(a,5) | ||
1017 | addl %esi, %ecx # e += rotl32(a,5) | ||
1018 | rorl $2, %ebp # b = rotl32(b,30) | ||
1019 | # 63 | ||
1020 | xorl %r12d, %r15d # W[n & 15] ^= W[(n+13) & 15] | ||
1021 | xorl -32+4*7(%rsp), %r15d # ^W[(n+8) & 15] | ||
1022 | xorl -32+4*1(%rsp), %r15d # ^W[(n+2) & 15] | ||
1023 | roll %r15d # | ||
1024 | movl %ebp, %edi # c | ||
1025 | xorl %eax, %edi # ^d | ||
1026 | xorl %edx, %edi # ^b | ||
1027 | leal -0x359D3E2A(%rbx,%r15), %ebx # e += RCONST + W[n & 15] | ||
1028 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
1029 | movl %ecx, %esi # | ||
1030 | roll $5, %esi # rotl32(a,5) | ||
1031 | addl %esi, %ebx # e += rotl32(a,5) | ||
1032 | rorl $2, %edx # b = rotl32(b,30) | ||
1033 | # 64 | ||
1034 | movl %r13d, %esi # W[(n+13) & 15] | ||
1035 | xorl %r8d, %esi # ^W[(n+8) & 15] | ||
1036 | xorl -32+4*2(%rsp), %esi # ^W[(n+2) & 15] | ||
1037 | xorl -32+4*0(%rsp), %esi # ^W[n & 15] | ||
1038 | roll %esi # | ||
1039 | movl %esi, -32+4*0(%rsp) # store to W[n & 15] | ||
1040 | movl %edx, %edi # c | ||
1041 | xorl %ebp, %edi # ^d | ||
1042 | xorl %ecx, %edi # ^b | ||
1043 | leal -0x359D3E2A(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
1044 | addl %edi, %eax # e += (c ^ d ^ b) | ||
1045 | movl %ebx, %esi # | ||
1046 | roll $5, %esi # rotl32(a,5) | ||
1047 | addl %esi, %eax # e += rotl32(a,5) | ||
1048 | rorl $2, %ecx # b = rotl32(b,30) | ||
1049 | # 65 | ||
1050 | movl %r14d, %esi # W[(n+13) & 15] | ||
1051 | xorl %r9d, %esi # ^W[(n+8) & 15] | ||
1052 | xorl -32+4*3(%rsp), %esi # ^W[(n+2) & 15] | ||
1053 | xorl -32+4*1(%rsp), %esi # ^W[n & 15] | ||
1054 | roll %esi # | ||
1055 | movl %esi, -32+4*1(%rsp) # store to W[n & 15] | ||
1056 | movl %ecx, %edi # c | ||
1057 | xorl %edx, %edi # ^d | ||
1058 | xorl %ebx, %edi # ^b | ||
1059 | leal -0x359D3E2A(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
1060 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
1061 | movl %eax, %esi # | ||
1062 | roll $5, %esi # rotl32(a,5) | ||
1063 | addl %esi, %ebp # e += rotl32(a,5) | ||
1064 | rorl $2, %ebx # b = rotl32(b,30) | ||
1065 | # 66 | ||
1066 | movl %r15d, %esi # W[(n+13) & 15] | ||
1067 | xorl %r10d, %esi # ^W[(n+8) & 15] | ||
1068 | xorl -32+4*4(%rsp), %esi # ^W[(n+2) & 15] | ||
1069 | xorl -32+4*2(%rsp), %esi # ^W[n & 15] | ||
1070 | roll %esi # | ||
1071 | movl %esi, -32+4*2(%rsp) # store to W[n & 15] | ||
1072 | movl %ebx, %edi # c | ||
1073 | xorl %ecx, %edi # ^d | ||
1074 | xorl %eax, %edi # ^b | ||
1075 | leal -0x359D3E2A(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
1076 | addl %edi, %edx # e += (c ^ d ^ b) | ||
1077 | movl %ebp, %esi # | ||
1078 | roll $5, %esi # rotl32(a,5) | ||
1079 | addl %esi, %edx # e += rotl32(a,5) | ||
1080 | rorl $2, %eax # b = rotl32(b,30) | ||
1081 | # 67 | ||
1082 | movl -32+4*0(%rsp), %esi # W[(n+13) & 15] | ||
1083 | xorl %r11d, %esi # ^W[(n+8) & 15] | ||
1084 | xorl -32+4*5(%rsp), %esi # ^W[(n+2) & 15] | ||
1085 | xorl -32+4*3(%rsp), %esi # ^W[n & 15] | ||
1086 | roll %esi # | ||
1087 | movl %esi, -32+4*3(%rsp) # store to W[n & 15] | ||
1088 | movl %eax, %edi # c | ||
1089 | xorl %ebx, %edi # ^d | ||
1090 | xorl %ebp, %edi # ^b | ||
1091 | leal -0x359D3E2A(%rcx,%rsi), %ecx # e += RCONST + W[n & 15] | ||
1092 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
1093 | movl %edx, %esi # | ||
1094 | roll $5, %esi # rotl32(a,5) | ||
1095 | addl %esi, %ecx # e += rotl32(a,5) | ||
1096 | rorl $2, %ebp # b = rotl32(b,30) | ||
1097 | # 68 | ||
1098 | movl -32+4*1(%rsp), %esi # W[(n+13) & 15] | ||
1099 | xorl %r12d, %esi # ^W[(n+8) & 15] | ||
1100 | xorl -32+4*6(%rsp), %esi # ^W[(n+2) & 15] | ||
1101 | xorl -32+4*4(%rsp), %esi # ^W[n & 15] | ||
1102 | roll %esi # | ||
1103 | movl %esi, -32+4*4(%rsp) # store to W[n & 15] | ||
1104 | movl %ebp, %edi # c | ||
1105 | xorl %eax, %edi # ^d | ||
1106 | xorl %edx, %edi # ^b | ||
1107 | leal -0x359D3E2A(%rbx,%rsi), %ebx # e += RCONST + W[n & 15] | ||
1108 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
1109 | movl %ecx, %esi # | ||
1110 | roll $5, %esi # rotl32(a,5) | ||
1111 | addl %esi, %ebx # e += rotl32(a,5) | ||
1112 | rorl $2, %edx # b = rotl32(b,30) | ||
1113 | # 69 | ||
1114 | movl -32+4*2(%rsp), %esi # W[(n+13) & 15] | ||
1115 | xorl %r13d, %esi # ^W[(n+8) & 15] | ||
1116 | xorl -32+4*7(%rsp), %esi # ^W[(n+2) & 15] | ||
1117 | xorl -32+4*5(%rsp), %esi # ^W[n & 15] | ||
1118 | roll %esi # | ||
1119 | movl %esi, -32+4*5(%rsp) # store to W[n & 15] | ||
1120 | movl %edx, %edi # c | ||
1121 | xorl %ebp, %edi # ^d | ||
1122 | xorl %ecx, %edi # ^b | ||
1123 | leal -0x359D3E2A(%rax,%rsi), %eax # e += RCONST + W[n & 15] | ||
1124 | addl %edi, %eax # e += (c ^ d ^ b) | ||
1125 | movl %ebx, %esi # | ||
1126 | roll $5, %esi # rotl32(a,5) | ||
1127 | addl %esi, %eax # e += rotl32(a,5) | ||
1128 | rorl $2, %ecx # b = rotl32(b,30) | ||
1129 | # 70 | ||
1130 | movl -32+4*3(%rsp), %esi # W[(n+13) & 15] | ||
1131 | xorl %r14d, %esi # ^W[(n+8) & 15] | ||
1132 | xorl %r8d, %esi # ^W[(n+2) & 15] | ||
1133 | xorl -32+4*6(%rsp), %esi # ^W[n & 15] | ||
1134 | roll %esi # | ||
1135 | movl %esi, -32+4*6(%rsp) # store to W[n & 15] | ||
1136 | movl %ecx, %edi # c | ||
1137 | xorl %edx, %edi # ^d | ||
1138 | xorl %ebx, %edi # ^b | ||
1139 | leal -0x359D3E2A(%rbp,%rsi), %ebp # e += RCONST + W[n & 15] | ||
1140 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
1141 | movl %eax, %esi # | ||
1142 | roll $5, %esi # rotl32(a,5) | ||
1143 | addl %esi, %ebp # e += rotl32(a,5) | ||
1144 | rorl $2, %ebx # b = rotl32(b,30) | ||
1145 | # 71 | ||
1146 | movl -32+4*4(%rsp), %esi # W[(n+13) & 15] | ||
1147 | xorl %r15d, %esi # ^W[(n+8) & 15] | ||
1148 | xorl %r9d, %esi # ^W[(n+2) & 15] | ||
1149 | xorl -32+4*7(%rsp), %esi # ^W[n & 15] | ||
1150 | roll %esi # | ||
1151 | movl %esi, -32+4*7(%rsp) # store to W[n & 15] | ||
1152 | movl %ebx, %edi # c | ||
1153 | xorl %ecx, %edi # ^d | ||
1154 | xorl %eax, %edi # ^b | ||
1155 | leal -0x359D3E2A(%rdx,%rsi), %edx # e += RCONST + W[n & 15] | ||
1156 | addl %edi, %edx # e += (c ^ d ^ b) | ||
1157 | movl %ebp, %esi # | ||
1158 | roll $5, %esi # rotl32(a,5) | ||
1159 | addl %esi, %edx # e += rotl32(a,5) | ||
1160 | rorl $2, %eax # b = rotl32(b,30) | ||
1161 | # 72 | ||
1162 | xorl -32+4*5(%rsp), %r8d # W[n & 15] ^= W[(n+13) & 15] | ||
1163 | xorl -32+4*0(%rsp), %r8d # ^W[(n+8) & 15] | ||
1164 | xorl %r10d, %r8d # ^W[(n+2) & 15] | ||
1165 | roll %r8d # | ||
1166 | movl %eax, %edi # c | ||
1167 | xorl %ebx, %edi # ^d | ||
1168 | xorl %ebp, %edi # ^b | ||
1169 | leal -0x359D3E2A(%rcx,%r8), %ecx # e += RCONST + W[n & 15] | ||
1170 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
1171 | movl %edx, %esi # | ||
1172 | roll $5, %esi # rotl32(a,5) | ||
1173 | addl %esi, %ecx # e += rotl32(a,5) | ||
1174 | rorl $2, %ebp # b = rotl32(b,30) | ||
1175 | # 73 | ||
1176 | xorl -32+4*6(%rsp), %r9d # W[n & 15] ^= W[(n+13) & 15] | ||
1177 | xorl -32+4*1(%rsp), %r9d # ^W[(n+8) & 15] | ||
1178 | xorl %r11d, %r9d # ^W[(n+2) & 15] | ||
1179 | roll %r9d # | ||
1180 | movl %ebp, %edi # c | ||
1181 | xorl %eax, %edi # ^d | ||
1182 | xorl %edx, %edi # ^b | ||
1183 | leal -0x359D3E2A(%rbx,%r9), %ebx # e += RCONST + W[n & 15] | ||
1184 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
1185 | movl %ecx, %esi # | ||
1186 | roll $5, %esi # rotl32(a,5) | ||
1187 | addl %esi, %ebx # e += rotl32(a,5) | ||
1188 | rorl $2, %edx # b = rotl32(b,30) | ||
1189 | # 74 | ||
1190 | xorl -32+4*7(%rsp), %r10d # W[n & 15] ^= W[(n+13) & 15] | ||
1191 | xorl -32+4*2(%rsp), %r10d # ^W[(n+8) & 15] | ||
1192 | xorl %r12d, %r10d # ^W[(n+2) & 15] | ||
1193 | roll %r10d # | ||
1194 | movl %edx, %edi # c | ||
1195 | xorl %ebp, %edi # ^d | ||
1196 | xorl %ecx, %edi # ^b | ||
1197 | leal -0x359D3E2A(%rax,%r10), %eax # e += RCONST + W[n & 15] | ||
1198 | addl %edi, %eax # e += (c ^ d ^ b) | ||
1199 | movl %ebx, %esi # | ||
1200 | roll $5, %esi # rotl32(a,5) | ||
1201 | addl %esi, %eax # e += rotl32(a,5) | ||
1202 | rorl $2, %ecx # b = rotl32(b,30) | ||
1203 | # 75 | ||
1204 | xorl %r8d, %r11d # W[n & 15] ^= W[(n+13) & 15] | ||
1205 | xorl -32+4*3(%rsp), %r11d # ^W[(n+8) & 15] | ||
1206 | xorl %r13d, %r11d # ^W[(n+2) & 15] | ||
1207 | roll %r11d # | ||
1208 | movl %ecx, %edi # c | ||
1209 | xorl %edx, %edi # ^d | ||
1210 | xorl %ebx, %edi # ^b | ||
1211 | leal -0x359D3E2A(%rbp,%r11), %ebp # e += RCONST + W[n & 15] | ||
1212 | addl %edi, %ebp # e += (c ^ d ^ b) | ||
1213 | movl %eax, %esi # | ||
1214 | roll $5, %esi # rotl32(a,5) | ||
1215 | addl %esi, %ebp # e += rotl32(a,5) | ||
1216 | rorl $2, %ebx # b = rotl32(b,30) | ||
1217 | # 76 | ||
1218 | xorl %r9d, %r12d # W[n & 15] ^= W[(n+13) & 15] | ||
1219 | xorl -32+4*4(%rsp), %r12d # ^W[(n+8) & 15] | ||
1220 | xorl %r14d, %r12d # ^W[(n+2) & 15] | ||
1221 | roll %r12d # | ||
1222 | movl %ebx, %edi # c | ||
1223 | xorl %ecx, %edi # ^d | ||
1224 | xorl %eax, %edi # ^b | ||
1225 | leal -0x359D3E2A(%rdx,%r12), %edx # e += RCONST + W[n & 15] | ||
1226 | addl %edi, %edx # e += (c ^ d ^ b) | ||
1227 | movl %ebp, %esi # | ||
1228 | roll $5, %esi # rotl32(a,5) | ||
1229 | addl %esi, %edx # e += rotl32(a,5) | ||
1230 | rorl $2, %eax # b = rotl32(b,30) | ||
1231 | # 77 | ||
1232 | xorl %r10d, %r13d # W[n & 15] ^= W[(n+13) & 15] | ||
1233 | xorl -32+4*5(%rsp), %r13d # ^W[(n+8) & 15] | ||
1234 | xorl %r15d, %r13d # ^W[(n+2) & 15] | ||
1235 | roll %r13d # | ||
1236 | movl %eax, %edi # c | ||
1237 | xorl %ebx, %edi # ^d | ||
1238 | xorl %ebp, %edi # ^b | ||
1239 | leal -0x359D3E2A(%rcx,%r13), %ecx # e += RCONST + W[n & 15] | ||
1240 | addl %edi, %ecx # e += (c ^ d ^ b) | ||
1241 | movl %edx, %esi # | ||
1242 | roll $5, %esi # rotl32(a,5) | ||
1243 | addl %esi, %ecx # e += rotl32(a,5) | ||
1244 | rorl $2, %ebp # b = rotl32(b,30) | ||
1245 | # 78 | ||
1246 | xorl %r11d, %r14d # W[n & 15] ^= W[(n+13) & 15] | ||
1247 | xorl -32+4*6(%rsp), %r14d # ^W[(n+8) & 15] | ||
1248 | xorl -32+4*0(%rsp), %r14d # ^W[(n+2) & 15] | ||
1249 | roll %r14d # | ||
1250 | movl %ebp, %edi # c | ||
1251 | xorl %eax, %edi # ^d | ||
1252 | xorl %edx, %edi # ^b | ||
1253 | leal -0x359D3E2A(%rbx,%r14), %ebx # e += RCONST + W[n & 15] | ||
1254 | addl %edi, %ebx # e += (c ^ d ^ b) | ||
1255 | movl %ecx, %esi # | ||
1256 | roll $5, %esi # rotl32(a,5) | ||
1257 | addl %esi, %ebx # e += rotl32(a,5) | ||
1258 | rorl $2, %edx # b = rotl32(b,30) | ||
1259 | # 79 | ||
1260 | xorl %r12d, %r15d # W[n & 15] ^= W[(n+13) & 15] | ||
1261 | xorl -32+4*7(%rsp), %r15d # ^W[(n+8) & 15] | ||
1262 | xorl -32+4*1(%rsp), %r15d # ^W[(n+2) & 15] | ||
1263 | roll %r15d # | ||
1264 | movl %edx, %edi # c | ||
1265 | xorl %ebp, %edi # ^d | ||
1266 | xorl %ecx, %edi # ^b | ||
1267 | leal -0x359D3E2A(%rax,%r15), %eax # e += RCONST + W[n & 15] | ||
1268 | addl %edi, %eax # e += (c ^ d ^ b) | ||
1269 | movl %ebx, %esi # | ||
1270 | roll $5, %esi # rotl32(a,5) | ||
1271 | addl %esi, %eax # e += rotl32(a,5) | ||
1272 | rorl $2, %ecx # b = rotl32(b,30) | ||
1273 | |||
1274 | popq %rdi # | ||
1275 | popq %r12 # | ||
1276 | addl %eax, 80(%rdi) # ctx->hash[0] += a | ||
1277 | popq %r13 # | ||
1278 | addl %ebx, 84(%rdi) # ctx->hash[1] += b | ||
1279 | popq %r14 # | ||
1280 | addl %ecx, 88(%rdi) # ctx->hash[2] += c | ||
1281 | popq %r15 # | ||
1282 | addl %edx, 92(%rdi) # ctx->hash[3] += d | ||
1283 | popq %rbx # | ||
1284 | addl %ebp, 96(%rdi) # ctx->hash[4] += e | ||
1285 | popq %rbp # | ||
1286 | |||
1287 | ret | ||
1288 | .size sha1_process_block64, .-sha1_process_block64 | ||
1289 | #endif | ||
diff --git a/libbb/hash_md5_sha_x86-64.S.sh b/libbb/hash_md5_sha_x86-64.S.sh new file mode 100755 index 000000000..7e50b64fb --- /dev/null +++ b/libbb/hash_md5_sha_x86-64.S.sh | |||
@@ -0,0 +1,281 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # We don't regenerate it on every "make" invocation - only by hand. | ||
4 | # The reason is that the changes to generated code are difficult | ||
5 | # to visualize by looking only at this script, it helps when the commit | ||
6 | # also contains the diff of the generated file. | ||
7 | exec >hash_md5_sha_x86-64.S | ||
8 | |||
9 | echo \ | ||
10 | '### Generated by hash_md5_sha_x86-64.S.sh ### | ||
11 | |||
12 | #if CONFIG_SHA1_SMALL == 0 && defined(__GNUC__) && defined(__x86_64__) | ||
13 | .section .text.sha1_process_block64,"ax",@progbits | ||
14 | .globl sha1_process_block64 | ||
15 | .hidden sha1_process_block64 | ||
16 | .type sha1_process_block64, @function | ||
17 | |||
18 | .balign 8 # allow decoders to fetch at least 5 first insns | ||
19 | sha1_process_block64: | ||
20 | pushq %rbp # 1 byte insn | ||
21 | pushq %rbx # 1 byte insn | ||
22 | pushq %r15 # 2 byte insn | ||
23 | pushq %r14 # 2 byte insn | ||
24 | pushq %r13 # 2 byte insn | ||
25 | pushq %r12 # 2 byte insn | ||
26 | pushq %rdi # we need ctx at the end | ||
27 | |||
28 | #Register and stack use: | ||
29 | # eax..edx: a..d | ||
30 | # ebp: e | ||
31 | # esi,edi: temps | ||
32 | # -32+4*n(%rsp),r8...r15: W[0..7,8..15] | ||
33 | # (TODO: actually W[0..7] are used a bit more often, put _them_ into r8..r15?) | ||
34 | movl $3, %eax | ||
35 | 1: | ||
36 | movq (%rdi,%rax,8), %rsi | ||
37 | bswapq %rsi | ||
38 | rolq $32, %rsi | ||
39 | movq %rsi, -32(%rsp,%rax,8) | ||
40 | decl %eax | ||
41 | jns 1b | ||
42 | |||
43 | movl 80(%rdi), %eax # a = ctx->hash[0] | ||
44 | movl 84(%rdi), %ebx # b = ctx->hash[1] | ||
45 | movl 88(%rdi), %ecx # c = ctx->hash[2] | ||
46 | movl 92(%rdi), %edx # d = ctx->hash[3] | ||
47 | movl 96(%rdi), %ebp # e = ctx->hash[4] | ||
48 | |||
49 | movq 4*8(%rdi), %r8 | ||
50 | movq 4*10(%rdi), %r10 | ||
51 | bswapq %r8 | ||
52 | bswapq %r10 | ||
53 | movq 4*12(%rdi), %r12 | ||
54 | movq 4*14(%rdi), %r14 | ||
55 | bswapq %r12 | ||
56 | bswapq %r14 | ||
57 | movl %r8d, %r9d | ||
58 | shrq $32, %r8 | ||
59 | movl %r10d, %r11d | ||
60 | shrq $32, %r10 | ||
61 | movl %r12d, %r13d | ||
62 | shrq $32, %r12 | ||
63 | movl %r14d, %r15d | ||
64 | shrq $32, %r14 | ||
65 | ' | ||
66 | W32() { | ||
67 | test "$1" || exit 1 | ||
68 | test "$1" -lt 0 && exit 1 | ||
69 | test "$1" -gt 15 && exit 1 | ||
70 | test "$1" -lt 8 && echo "-32+4*$1(%rsp)" | ||
71 | test "$1" -ge 8 && echo "%r${1}d" | ||
72 | } | ||
73 | |||
74 | # It's possible to interleave insns in rounds to mostly eliminate | ||
75 | # dependency chains, but this likely to only help old Pentium-based | ||
76 | # CPUs (ones without OOO, which can only simultaneously execute a pair | ||
77 | # of _adjacent_ insns). | ||
78 | # Testing on old-ish Silvermont CPU (which has OOO window of only | ||
79 | # about ~8 insns) shows very small (~1%) speedup. | ||
80 | |||
81 | RD1A() { | ||
82 | local a=$1;local b=$2;local c=$3;local d=$4;local e=$5 | ||
83 | local n=$(($6)) | ||
84 | local n0=$(((n+0) & 15)) | ||
85 | echo " | ||
86 | # $n | ||
87 | ";test $n0 = 0 && echo " | ||
88 | # W[0], already in %esi | ||
89 | ";test $n0 != 0 && test $n0 -lt 8 && echo " | ||
90 | movl `W32 $n0`, %esi # W[n] | ||
91 | ";test $n0 -ge 8 && echo " | ||
92 | # W[n], in %r$n0 | ||
93 | ";echo " | ||
94 | movl %e$c, %edi # c | ||
95 | xorl %e$d, %edi # ^d | ||
96 | andl %e$b, %edi # &b | ||
97 | xorl %e$d, %edi # (((c ^ d) & b) ^ d) | ||
98 | ";test $n0 -lt 8 && echo " | ||
99 | leal $RCONST(%r$e,%rsi), %e$e # e += RCONST + W[n] | ||
100 | ";test $n0 -ge 8 && echo " | ||
101 | leal $RCONST(%r$e,%r$n0), %e$e # e += RCONST + W[n] | ||
102 | ";echo " | ||
103 | addl %edi, %e$e # e += (((c ^ d) & b) ^ d) | ||
104 | movl %e$a, %esi # | ||
105 | roll \$5, %esi # rotl32(a,5) | ||
106 | addl %esi, %e$e # e += rotl32(a,5) | ||
107 | rorl \$2, %e$b # b = rotl32(b,30) | ||
108 | " | ||
109 | } | ||
110 | RD1B() { | ||
111 | local a=$1;local b=$2;local c=$3;local d=$4;local e=$5 | ||
112 | local n=$(($6)) | ||
113 | local n13=$(((n+13) & 15)) | ||
114 | local n8=$(((n+8) & 15)) | ||
115 | local n2=$(((n+2) & 15)) | ||
116 | local n0=$(((n+0) & 15)) | ||
117 | echo " | ||
118 | # $n | ||
119 | ";test $n0 -lt 8 && echo " | ||
120 | movl `W32 $n13`, %esi # W[(n+13) & 15] | ||
121 | xorl `W32 $n8`, %esi # ^W[(n+8) & 15] | ||
122 | xorl `W32 $n2`, %esi # ^W[(n+2) & 15] | ||
123 | xorl `W32 $n0`, %esi # ^W[n & 15] | ||
124 | roll %esi # | ||
125 | movl %esi, `W32 $n0` # store to W[n & 15] | ||
126 | ";test $n0 -ge 8 && echo " | ||
127 | xorl `W32 $n13`, `W32 $n0` # W[n & 15] ^= W[(n+13) & 15] | ||
128 | xorl `W32 $n8`, `W32 $n0` # ^W[(n+8) & 15] | ||
129 | xorl `W32 $n2`, `W32 $n0` # ^W[(n+2) & 15] | ||
130 | roll `W32 $n0` # | ||
131 | ";echo " | ||
132 | movl %e$c, %edi # c | ||
133 | xorl %e$d, %edi # ^d | ||
134 | andl %e$b, %edi # &b | ||
135 | xorl %e$d, %edi # (((c ^ d) & b) ^ d) | ||
136 | ";test $n0 -lt 8 && echo " | ||
137 | leal $RCONST(%r$e,%rsi), %e$e # e += RCONST + W[n & 15] | ||
138 | ";test $n0 -ge 8 && echo " | ||
139 | leal $RCONST(%r$e,%r$n0), %e$e # e += RCONST + W[n & 15] | ||
140 | ";echo " | ||
141 | addl %edi, %e$e # e += (((c ^ d) & b) ^ d) | ||
142 | movl %e$a, %esi # | ||
143 | roll \$5, %esi # rotl32(a,5) | ||
144 | addl %esi, %e$e # e += rotl32(a,5) | ||
145 | rorl \$2, %e$b # b = rotl32(b,30) | ||
146 | " | ||
147 | } | ||
148 | { | ||
149 | RCONST=0x5A827999 | ||
150 | RD1A ax bx cx dx bp 0; RD1A bp ax bx cx dx 1; RD1A dx bp ax bx cx 2; RD1A cx dx bp ax bx 3; RD1A bx cx dx bp ax 4 | ||
151 | RD1A ax bx cx dx bp 5; RD1A bp ax bx cx dx 6; RD1A dx bp ax bx cx 7; RD1A cx dx bp ax bx 8; RD1A bx cx dx bp ax 9 | ||
152 | RD1A ax bx cx dx bp 10; RD1A bp ax bx cx dx 11; RD1A dx bp ax bx cx 12; RD1A cx dx bp ax bx 13; RD1A bx cx dx bp ax 14 | ||
153 | RD1A ax bx cx dx bp 15; RD1B bp ax bx cx dx 16; RD1B dx bp ax bx cx 17; RD1B cx dx bp ax bx 18; RD1B bx cx dx bp ax 19 | ||
154 | } | grep -v '^$' | ||
155 | |||
156 | RD2() { | ||
157 | local a=$1;local b=$2;local c=$3;local d=$4;local e=$5 | ||
158 | local n=$(($6)) | ||
159 | local n13=$(((n+13) & 15)) | ||
160 | local n8=$(((n+8) & 15)) | ||
161 | local n2=$(((n+2) & 15)) | ||
162 | local n0=$(((n+0) & 15)) | ||
163 | echo " | ||
164 | # $n | ||
165 | ";test $n0 -lt 8 && echo " | ||
166 | movl `W32 $n13`, %esi # W[(n+13) & 15] | ||
167 | xorl `W32 $n8`, %esi # ^W[(n+8) & 15] | ||
168 | xorl `W32 $n2`, %esi # ^W[(n+2) & 15] | ||
169 | xorl `W32 $n0`, %esi # ^W[n & 15] | ||
170 | roll %esi # | ||
171 | movl %esi, `W32 $n0` # store to W[n & 15] | ||
172 | ";test $n0 -ge 8 && echo " | ||
173 | xorl `W32 $n13`, `W32 $n0` # W[n & 15] ^= W[(n+13) & 15] | ||
174 | xorl `W32 $n8`, `W32 $n0` # ^W[(n+8) & 15] | ||
175 | xorl `W32 $n2`, `W32 $n0` # ^W[(n+2) & 15] | ||
176 | roll `W32 $n0` # | ||
177 | ";echo " | ||
178 | movl %e$c, %edi # c | ||
179 | xorl %e$d, %edi # ^d | ||
180 | xorl %e$b, %edi # ^b | ||
181 | ";test $n0 -lt 8 && echo " | ||
182 | leal $RCONST(%r$e,%rsi), %e$e # e += RCONST + W[n & 15] | ||
183 | ";test $n0 -ge 8 && echo " | ||
184 | leal $RCONST(%r$e,%r$n0), %e$e # e += RCONST + W[n & 15] | ||
185 | ";echo " | ||
186 | addl %edi, %e$e # e += (c ^ d ^ b) | ||
187 | movl %e$a, %esi # | ||
188 | roll \$5, %esi # rotl32(a,5) | ||
189 | addl %esi, %e$e # e += rotl32(a,5) | ||
190 | rorl \$2, %e$b # b = rotl32(b,30) | ||
191 | " | ||
192 | } | ||
193 | { | ||
194 | RCONST=0x6ED9EBA1 | ||
195 | RD2 ax bx cx dx bp 20; RD2 bp ax bx cx dx 21; RD2 dx bp ax bx cx 22; RD2 cx dx bp ax bx 23; RD2 bx cx dx bp ax 24 | ||
196 | RD2 ax bx cx dx bp 25; RD2 bp ax bx cx dx 26; RD2 dx bp ax bx cx 27; RD2 cx dx bp ax bx 28; RD2 bx cx dx bp ax 29 | ||
197 | RD2 ax bx cx dx bp 30; RD2 bp ax bx cx dx 31; RD2 dx bp ax bx cx 32; RD2 cx dx bp ax bx 33; RD2 bx cx dx bp ax 34 | ||
198 | RD2 ax bx cx dx bp 35; RD2 bp ax bx cx dx 36; RD2 dx bp ax bx cx 37; RD2 cx dx bp ax bx 38; RD2 bx cx dx bp ax 39 | ||
199 | } | grep -v '^$' | ||
200 | |||
201 | RD3() { | ||
202 | local a=$1;local b=$2;local c=$3;local d=$4;local e=$5 | ||
203 | local n=$(($6)) | ||
204 | local n13=$(((n+13) & 15)) | ||
205 | local n8=$(((n+8) & 15)) | ||
206 | local n2=$(((n+2) & 15)) | ||
207 | local n0=$(((n+0) & 15)) | ||
208 | echo " | ||
209 | # $n | ||
210 | movl %e$b, %edi # di: b | ||
211 | movl %e$b, %esi # si: b | ||
212 | orl %e$c, %edi # di: b | c | ||
213 | andl %e$c, %esi # si: b & c | ||
214 | andl %e$d, %edi # di: (b | c) & d | ||
215 | orl %esi, %edi # ((b | c) & d) | (b & c) | ||
216 | ";test $n0 -lt 8 && echo " | ||
217 | movl `W32 $n13`, %esi # W[(n+13) & 15] | ||
218 | xorl `W32 $n8`, %esi # ^W[(n+8) & 15] | ||
219 | xorl `W32 $n2`, %esi # ^W[(n+2) & 15] | ||
220 | xorl `W32 $n0`, %esi # ^W[n & 15] | ||
221 | roll %esi # | ||
222 | movl %esi, `W32 $n0` # store to W[n & 15] | ||
223 | ";test $n0 -ge 8 && echo " | ||
224 | xorl `W32 $n13`, `W32 $n0` # W[n & 15] ^= W[(n+13) & 15] | ||
225 | xorl `W32 $n8`, `W32 $n0` # ^W[(n+8) & 15] | ||
226 | xorl `W32 $n2`, `W32 $n0` # ^W[(n+2) & 15] | ||
227 | roll `W32 $n0` # | ||
228 | ";echo " | ||
229 | addl %edi, %e$e # += ((b | c) & d) | (b & c) | ||
230 | ";test $n0 -lt 8 && echo " | ||
231 | leal $RCONST(%r$e,%rsi), %e$e # e += RCONST + W[n & 15] | ||
232 | ";test $n0 -ge 8 && echo " | ||
233 | leal $RCONST(%r$e,%r$n0), %e$e # e += RCONST + W[n & 15] | ||
234 | ";echo " | ||
235 | movl %e$a, %esi # | ||
236 | roll \$5, %esi # rotl32(a,5) | ||
237 | addl %esi, %e$e # e += rotl32(a,5) | ||
238 | rorl \$2, %e$b # b = rotl32(b,30) | ||
239 | " | ||
240 | } | ||
241 | { | ||
242 | #RCONST=0x8F1BBCDC "out of range for signed 32bit displacement" | ||
243 | RCONST=-0x70E44324 | ||
244 | RD3 ax bx cx dx bp 40; RD3 bp ax bx cx dx 41; RD3 dx bp ax bx cx 42; RD3 cx dx bp ax bx 43; RD3 bx cx dx bp ax 44 | ||
245 | RD3 ax bx cx dx bp 45; RD3 bp ax bx cx dx 46; RD3 dx bp ax bx cx 47; RD3 cx dx bp ax bx 48; RD3 bx cx dx bp ax 49 | ||
246 | RD3 ax bx cx dx bp 50; RD3 bp ax bx cx dx 51; RD3 dx bp ax bx cx 52; RD3 cx dx bp ax bx 53; RD3 bx cx dx bp ax 54 | ||
247 | RD3 ax bx cx dx bp 55; RD3 bp ax bx cx dx 56; RD3 dx bp ax bx cx 57; RD3 cx dx bp ax bx 58; RD3 bx cx dx bp ax 59 | ||
248 | } | grep -v '^$' | ||
249 | |||
250 | # Round 4 has the same logic as round 2, only n and RCONST are different | ||
251 | { | ||
252 | #RCONST=0xCA62C1D6 "out of range for signed 32bit displacement" | ||
253 | RCONST=-0x359D3E2A | ||
254 | RD2 ax bx cx dx bp 60; RD2 bp ax bx cx dx 61; RD2 dx bp ax bx cx 62; RD2 cx dx bp ax bx 63; RD2 bx cx dx bp ax 64 | ||
255 | RD2 ax bx cx dx bp 65; RD2 bp ax bx cx dx 66; RD2 dx bp ax bx cx 67; RD2 cx dx bp ax bx 68; RD2 bx cx dx bp ax 69 | ||
256 | RD2 ax bx cx dx bp 70; RD2 bp ax bx cx dx 71; RD2 dx bp ax bx cx 72; RD2 cx dx bp ax bx 73; RD2 bx cx dx bp ax 74 | ||
257 | RD2 ax bx cx dx bp 75; RD2 bp ax bx cx dx 76; RD2 dx bp ax bx cx 77; RD2 cx dx bp ax bx 78; RD2 bx cx dx bp ax 79 | ||
258 | # Note: new W[n&15] values generated in last 3 iterations | ||
259 | # (W[13,14,15]) are unused after each of these iterations. | ||
260 | # Since we use r8..r15 for W[8..15], this does not matter. | ||
261 | # If we switch to e.g. using r8..r15 for W[0..7], then saving of W[13,14,15] | ||
262 | # (the "movl %esi, `W32 $n0`" insn) is a dead store and can be removed. | ||
263 | } | grep -v '^$' | ||
264 | |||
265 | echo " | ||
266 | popq %rdi # | ||
267 | popq %r12 # | ||
268 | addl %eax, 80(%rdi) # ctx->hash[0] += a | ||
269 | popq %r13 # | ||
270 | addl %ebx, 84(%rdi) # ctx->hash[1] += b | ||
271 | popq %r14 # | ||
272 | addl %ecx, 88(%rdi) # ctx->hash[2] += c | ||
273 | popq %r15 # | ||
274 | addl %edx, 92(%rdi) # ctx->hash[3] += d | ||
275 | popq %rbx # | ||
276 | addl %ebp, 96(%rdi) # ctx->hash[4] += e | ||
277 | popq %rbp # | ||
278 | |||
279 | ret | ||
280 | .size sha1_process_block64, .-sha1_process_block64 | ||
281 | #endif" | ||
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 151739ae2..62beb6a5d 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -313,7 +313,7 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) | |||
313 | /* fflush_all(); - add it in fork_or_rexec() if necessary */ | 313 | /* fflush_all(); - add it in fork_or_rexec() if necessary */ |
314 | 314 | ||
315 | if (fork_or_rexec(argv)) | 315 | if (fork_or_rexec(argv)) |
316 | _exit(EXIT_SUCCESS); /* parent */ | 316 | _exit_SUCCESS(); /* parent */ |
317 | /* if daemonizing, detach from stdio & ctty */ | 317 | /* if daemonizing, detach from stdio & ctty */ |
318 | setsid(); | 318 | setsid(); |
319 | dup2(fd, 0); | 319 | dup2(fd, 0); |
@@ -325,7 +325,7 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) | |||
325 | // * Prevent this: stop being a session leader. | 325 | // * Prevent this: stop being a session leader. |
326 | // */ | 326 | // */ |
327 | // if (fork_or_rexec(argv)) | 327 | // if (fork_or_rexec(argv)) |
328 | // _exit(EXIT_SUCCESS); /* parent */ | 328 | // _exit_SUCCESS(); /* parent */ |
329 | // } | 329 | // } |
330 | } | 330 | } |
331 | while (fd > 2) { | 331 | while (fd > 2) { |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 102b5a227..388b246ca 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -427,3 +427,13 @@ int FAST_FUNC wait4pid(pid_t pid) | |||
427 | return WTERMSIG(status) + 0x180; | 427 | return WTERMSIG(status) + 0x180; |
428 | return 0; | 428 | return 0; |
429 | } | 429 | } |
430 | |||
431 | void FAST_FUNC exit_SUCCESS(void) | ||
432 | { | ||
433 | exit(EXIT_SUCCESS); | ||
434 | } | ||
435 | |||
436 | void FAST_FUNC _exit_SUCCESS(void) | ||
437 | { | ||
438 | _exit(EXIT_SUCCESS); | ||
439 | } | ||
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index d7d8b1092..aae3b092d 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -91,13 +91,10 @@ char* FAST_FUNC xstrdup(const char *s) | |||
91 | 91 | ||
92 | // Die if we can't allocate n+1 bytes (space for the null terminator) and copy | 92 | // Die if we can't allocate n+1 bytes (space for the null terminator) and copy |
93 | // the (possibly truncated to length n) string into it. | 93 | // the (possibly truncated to length n) string into it. |
94 | char* FAST_FUNC xstrndup(const char *s, int n) | 94 | char* FAST_FUNC xstrndup(const char *s, size_t n) |
95 | { | 95 | { |
96 | char *t; | 96 | char *t; |
97 | 97 | ||
98 | if (ENABLE_DEBUG && s == NULL) | ||
99 | bb_simple_error_msg_and_die("xstrndup bug"); | ||
100 | |||
101 | t = strndup(s, n); | 98 | t = strndup(s, n); |
102 | 99 | ||
103 | if (t == NULL) | 100 | if (t == NULL) |
@@ -106,7 +103,7 @@ char* FAST_FUNC xstrndup(const char *s, int n) | |||
106 | return t; | 103 | return t; |
107 | } | 104 | } |
108 | 105 | ||
109 | void* FAST_FUNC xmemdup(const void *s, int n) | 106 | void* FAST_FUNC xmemdup(const void *s, size_t n) |
110 | { | 107 | { |
111 | return memcpy(xmalloc(n), s, n); | 108 | return memcpy(xmalloc(n), s, n); |
112 | } | 109 | } |
diff --git a/loginutils/getty.c b/loginutils/getty.c index 6c6d409f4..cd6378d80 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -484,7 +484,7 @@ static char *get_logname(void) | |||
484 | if (read(STDIN_FILENO, &c, 1) < 1) { | 484 | if (read(STDIN_FILENO, &c, 1) < 1) { |
485 | finalize_tty_attrs(); | 485 | finalize_tty_attrs(); |
486 | if (errno == EINTR || errno == EIO) | 486 | if (errno == EINTR || errno == EIO) |
487 | exit(EXIT_SUCCESS); | 487 | exit_SUCCESS(); |
488 | bb_simple_perror_msg_and_die(bb_msg_read_error); | 488 | bb_simple_perror_msg_and_die(bb_msg_read_error); |
489 | } | 489 | } |
490 | 490 | ||
@@ -511,7 +511,7 @@ static char *get_logname(void) | |||
511 | case CTL('C'): | 511 | case CTL('C'): |
512 | case CTL('D'): | 512 | case CTL('D'): |
513 | finalize_tty_attrs(); | 513 | finalize_tty_attrs(); |
514 | exit(EXIT_SUCCESS); | 514 | exit_SUCCESS(); |
515 | case '\0': | 515 | case '\0': |
516 | /* BREAK. If we have speeds to try, | 516 | /* BREAK. If we have speeds to try, |
517 | * return NULL (will switch speeds and return here) */ | 517 | * return NULL (will switch speeds and return here) */ |
@@ -538,7 +538,7 @@ static char *get_logname(void) | |||
538 | static void alarm_handler(int sig UNUSED_PARAM) | 538 | static void alarm_handler(int sig UNUSED_PARAM) |
539 | { | 539 | { |
540 | finalize_tty_attrs(); | 540 | finalize_tty_attrs(); |
541 | _exit(EXIT_SUCCESS); | 541 | _exit_SUCCESS(); |
542 | } | 542 | } |
543 | 543 | ||
544 | static void sleep10(void) | 544 | static void sleep10(void) |
diff --git a/loginutils/login.c b/loginutils/login.c index ce87e318a..569053c12 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -312,7 +312,7 @@ static void alarm_handler(int sig UNUSED_PARAM) | |||
312 | /* unix API is brain damaged regarding O_NONBLOCK, | 312 | /* unix API is brain damaged regarding O_NONBLOCK, |
313 | * we should undo it, or else we can affect other processes */ | 313 | * we should undo it, or else we can affect other processes */ |
314 | ndelay_off(STDOUT_FILENO); | 314 | ndelay_off(STDOUT_FILENO); |
315 | _exit(EXIT_SUCCESS); | 315 | _exit_SUCCESS(); |
316 | } | 316 | } |
317 | 317 | ||
318 | int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 318 | int login_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
diff --git a/loginutils/vlock.c b/loginutils/vlock.c index 334b7d2ad..720835c4b 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c | |||
@@ -128,5 +128,5 @@ int vlock_main(int argc UNUSED_PARAM, char **argv) | |||
128 | ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); | 128 | ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); |
129 | #endif | 129 | #endif |
130 | tcsetattr_stdin_TCSANOW(&oterm); | 130 | tcsetattr_stdin_TCSANOW(&oterm); |
131 | fflush_stdout_and_exit(EXIT_SUCCESS); | 131 | fflush_stdout_and_exit_SUCCESS(); |
132 | } | 132 | } |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index e5bb8a2d8..839d00fd0 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -453,7 +453,7 @@ int devfsd_main(int argc, char **argv) | |||
453 | DEVFSD_PROTOCOL_REVISION_DAEMON, bb_msg_proto_rev, proto_rev); | 453 | DEVFSD_PROTOCOL_REVISION_DAEMON, bb_msg_proto_rev, proto_rev); |
454 | if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) | 454 | if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) |
455 | bb_error_msg_and_die("%s mismatch!", bb_msg_proto_rev); | 455 | bb_error_msg_and_die("%s mismatch!", bb_msg_proto_rev); |
456 | exit(EXIT_SUCCESS); /* -v */ | 456 | exit_SUCCESS(); /* -v */ |
457 | } | 457 | } |
458 | /* Tell kernel we are special(i.e. we get to see hidden entries) */ | 458 | /* Tell kernel we are special(i.e. we get to see hidden entries) */ |
459 | xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0); | 459 | xioctl(fd, DEVFSDIOC_SET_EVENT_MASK, 0); |
@@ -474,7 +474,7 @@ int devfsd_main(int argc, char **argv) | |||
474 | dir_operation(SERVICE, mount_point, 0, NULL); | 474 | dir_operation(SERVICE, mount_point, 0, NULL); |
475 | 475 | ||
476 | if (ENABLE_DEVFSD_FG_NP && no_polling) | 476 | if (ENABLE_DEVFSD_FG_NP && no_polling) |
477 | exit(EXIT_SUCCESS); | 477 | exit_SUCCESS(); |
478 | 478 | ||
479 | if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG) | 479 | if (ENABLE_DEVFSD_VERBOSE || ENABLE_DEBUG) |
480 | logmode = LOGMODE_BOTH; | 480 | logmode = LOGMODE_BOTH; |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 01b4e8e2e..d8d8f6166 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1271,7 +1271,7 @@ static void identify(uint16_t *val) | |||
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | exit(EXIT_SUCCESS); | 1274 | exit_SUCCESS(); |
1275 | } | 1275 | } |
1276 | #endif | 1276 | #endif |
1277 | 1277 | ||
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index b25d49792..e3741eeba 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
@@ -1212,7 +1212,7 @@ static void NORETURN list_i2c_busses_and_exit(void) | |||
1212 | } | 1212 | } |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | exit(EXIT_SUCCESS); | 1215 | exit_SUCCESS(); |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | static void NORETURN no_support(const char *cmd) | 1218 | static void NORETURN no_support(const char *cmd) |
diff --git a/miscutils/less.c b/miscutils/less.c index 063c4d378..6da991a0e 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -333,7 +333,7 @@ static void print_statusline(const char *str) | |||
333 | } | 333 | } |
334 | 334 | ||
335 | /* Exit the program gracefully */ | 335 | /* Exit the program gracefully */ |
336 | static void less_exit(int code) | 336 | static void restore_tty(void) |
337 | { | 337 | { |
338 | set_tty_cooked(); | 338 | set_tty_cooked(); |
339 | if (!(G.kbd_fd_orig_flags & O_NONBLOCK)) | 339 | if (!(G.kbd_fd_orig_flags & O_NONBLOCK)) |
@@ -343,9 +343,12 @@ static void less_exit(int code) | |||
343 | #else | 343 | #else |
344 | printf(ESC"[?1049l"); | 344 | printf(ESC"[?1049l"); |
345 | #endif | 345 | #endif |
346 | if (code < 0) | 346 | } |
347 | kill_myself_with_sig(- code); /* does not return */ | 347 | |
348 | exit(code); | 348 | static NOINLINE void less_exit(void) |
349 | { | ||
350 | restore_tty(); | ||
351 | exit_SUCCESS(); | ||
349 | } | 352 | } |
350 | 353 | ||
351 | #if (ENABLE_FEATURE_LESS_DASHCMD && ENABLE_FEATURE_LESS_LINENUMS) \ | 354 | #if (ENABLE_FEATURE_LESS_DASHCMD && ENABLE_FEATURE_LESS_LINENUMS) \ |
@@ -949,7 +952,7 @@ static void buffer_print(void) | |||
949 | ) { | 952 | ) { |
950 | i = option_mask32 & FLAG_F ? 0 : cur_fline; | 953 | i = option_mask32 & FLAG_F ? 0 : cur_fline; |
951 | if (max_fline - i <= max_displayed_line) | 954 | if (max_fline - i <= max_displayed_line) |
952 | less_exit(EXIT_SUCCESS); | 955 | less_exit(); |
953 | } | 956 | } |
954 | status_print(); | 957 | status_print(); |
955 | } | 958 | } |
@@ -1186,7 +1189,7 @@ static int64_t getch_nowait(void) | |||
1186 | goto again; | 1189 | goto again; |
1187 | } | 1190 | } |
1188 | /* EOF/error (ssh session got killed etc) */ | 1191 | /* EOF/error (ssh session got killed etc) */ |
1189 | less_exit(EXIT_SUCCESS); | 1192 | less_exit(); |
1190 | } | 1193 | } |
1191 | set_tty_cooked(); | 1194 | set_tty_cooked(); |
1192 | return key64; | 1195 | return key64; |
@@ -1377,7 +1380,7 @@ static void colon_process(void) | |||
1377 | change_file(-1); | 1380 | change_file(-1); |
1378 | break; | 1381 | break; |
1379 | case 'q': | 1382 | case 'q': |
1380 | less_exit(EXIT_SUCCESS); | 1383 | less_exit(); |
1381 | break; | 1384 | break; |
1382 | case 'x': | 1385 | case 'x': |
1383 | change_file(0); | 1386 | change_file(0); |
@@ -1795,7 +1798,7 @@ static void keypress_process(int keypress) | |||
1795 | buffer_line(cur_fline); | 1798 | buffer_line(cur_fline); |
1796 | break; | 1799 | break; |
1797 | case 'q': case 'Q': | 1800 | case 'q': case 'Q': |
1798 | less_exit(EXIT_SUCCESS); | 1801 | less_exit(); |
1799 | break; | 1802 | break; |
1800 | #if ENABLE_FEATURE_LESS_MARKS | 1803 | #if ENABLE_FEATURE_LESS_MARKS |
1801 | case 'm': | 1804 | case 'm': |
@@ -1874,7 +1877,8 @@ static void keypress_process(int keypress) | |||
1874 | #if !ENABLE_PLATFORM_MINGW32 | 1877 | #if !ENABLE_PLATFORM_MINGW32 |
1875 | static void sig_catcher(int sig) | 1878 | static void sig_catcher(int sig) |
1876 | { | 1879 | { |
1877 | less_exit(- sig); | 1880 | restore_tty(); |
1881 | kill_myself_with_sig(sig); /* does not return */ | ||
1878 | } | 1882 | } |
1879 | #endif | 1883 | #endif |
1880 | 1884 | ||
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index d8e9c78f5..9f5a4b849 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -76,7 +76,7 @@ static void shutdown_on_signal(int sig UNUSED_PARAM) | |||
76 | { | 76 | { |
77 | remove_pidfile_std_path_and_ext("watchdog"); | 77 | remove_pidfile_std_path_and_ext("watchdog"); |
78 | shutdown_watchdog(); | 78 | shutdown_watchdog(); |
79 | _exit(EXIT_SUCCESS); | 79 | _exit_SUCCESS(); |
80 | } | 80 | } |
81 | 81 | ||
82 | static void watchdog_open(const char* device) | 82 | static void watchdog_open(const char* device) |
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index db44a2ed0..b61651621 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c | |||
@@ -415,7 +415,7 @@ static FAST_FUNC int fileAction(struct recursive_state *state, | |||
415 | /* Load was successful, there is nothing else to do. | 415 | /* Load was successful, there is nothing else to do. |
416 | * This can happen ONLY for "top-level" module load, | 416 | * This can happen ONLY for "top-level" module load, |
417 | * not a dep, because deps don't do dirscan. */ | 417 | * not a dep, because deps don't do dirscan. */ |
418 | exit(EXIT_SUCCESS); | 418 | exit_SUCCESS(); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
diff --git a/networking/arping.c b/networking/arping.c index d44d7d697..86f0221ed 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -159,7 +159,7 @@ static void finish(void) | |||
159 | if (option_mask32 & DAD) | 159 | if (option_mask32 & DAD) |
160 | exit(!!received); | 160 | exit(!!received); |
161 | if (option_mask32 & UNSOLICITED) | 161 | if (option_mask32 & UNSOLICITED) |
162 | exit(EXIT_SUCCESS); | 162 | exit_SUCCESS(); |
163 | exit(!received); | 163 | exit(!received); |
164 | } | 164 | } |
165 | 165 | ||
diff --git a/networking/httpd.c b/networking/httpd.c index c9daa0638..5f7b3a4dd 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -2865,7 +2865,7 @@ static void mingw_daemonize(char **argv) | |||
2865 | close(fd); | 2865 | close(fd); |
2866 | 2866 | ||
2867 | if (mingw_spawn_detach(new_argv)) | 2867 | if (mingw_spawn_detach(new_argv)) |
2868 | exit(EXIT_SUCCESS); /* parent */ | 2868 | exit_SUCCESS(); /* parent */ |
2869 | exit(EXIT_FAILURE); /* parent */ | 2869 | exit(EXIT_FAILURE); /* parent */ |
2870 | } | 2870 | } |
2871 | #endif | 2871 | #endif |
diff --git a/networking/inetd.c b/networking/inetd.c index e5352a555..e71be51c3 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -1208,7 +1208,7 @@ static void clean_up_and_exit(int sig UNUSED_PARAM) | |||
1208 | close(sep->se_fd); | 1208 | close(sep->se_fd); |
1209 | } | 1209 | } |
1210 | remove_pidfile_std_path_and_ext("inetd"); | 1210 | remove_pidfile_std_path_and_ext("inetd"); |
1211 | exit(EXIT_SUCCESS); | 1211 | exit_SUCCESS(); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1214 | int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
diff --git a/networking/nc.c b/networking/nc.c index 5525e41f9..d039e2055 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -287,7 +287,7 @@ int nc_main(int argc, char **argv) | |||
287 | nread = safe_read(pfds[fdidx].fd, iobuf, COMMON_BUFSIZE); | 287 | nread = safe_read(pfds[fdidx].fd, iobuf, COMMON_BUFSIZE); |
288 | if (fdidx != 0) { | 288 | if (fdidx != 0) { |
289 | if (nread < 1) | 289 | if (nread < 1) |
290 | exit(EXIT_SUCCESS); | 290 | exit_SUCCESS(); |
291 | ofd = STDOUT_FILENO; | 291 | ofd = STDOUT_FILENO; |
292 | } else { | 292 | } else { |
293 | if (nread < 1) { | 293 | if (nread < 1) { |
@@ -324,7 +324,7 @@ int nc_main(int argc, char **argv) | |||
324 | nread = safe_read(fd, iobuf, COMMON_BUFSIZE); | 324 | nread = safe_read(fd, iobuf, COMMON_BUFSIZE); |
325 | if (fd == cfd) { | 325 | if (fd == cfd) { |
326 | if (nread < 1) | 326 | if (nread < 1) |
327 | exit(EXIT_SUCCESS); | 327 | exit_SUCCESS(); |
328 | ofd = STDOUT_FILENO; | 328 | ofd = STDOUT_FILENO; |
329 | } else { | 329 | } else { |
330 | if (nread < 1) { | 330 | if (nread < 1) { |
diff --git a/networking/route.c b/networking/route.c index ff5daa8a7..26146f8e9 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -702,7 +702,7 @@ int route_main(int argc UNUSED_PARAM, char **argv) | |||
702 | #endif | 702 | #endif |
703 | bb_displayroutes(noresolve, opt & ROUTE_OPT_e); | 703 | bb_displayroutes(noresolve, opt & ROUTE_OPT_e); |
704 | 704 | ||
705 | fflush_stdout_and_exit(EXIT_SUCCESS); | 705 | fflush_stdout_and_exit_SUCCESS(); |
706 | } | 706 | } |
707 | 707 | ||
708 | /* Check verb. At the moment, must be add, del, or delete. */ | 708 | /* Check verb. At the moment, must be add, del, or delete. */ |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 581da1924..0805e464f 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -582,7 +582,7 @@ free_session(struct tsession *ts) | |||
582 | struct tsession *t; | 582 | struct tsession *t; |
583 | 583 | ||
584 | if (option_mask32 & OPT_INETD) | 584 | if (option_mask32 & OPT_INETD) |
585 | exit(EXIT_SUCCESS); | 585 | exit_SUCCESS(); |
586 | 586 | ||
587 | /* Unlink this telnet session from the session list */ | 587 | /* Unlink this telnet session from the session list */ |
588 | t = G.sessions; | 588 | t = G.sessions; |
diff --git a/runit/runsv.c b/runit/runsv.c index a4b8af494..6ad6bf46e 100644 --- a/runit/runsv.c +++ b/runit/runsv.c | |||
@@ -700,7 +700,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv) | |||
700 | 700 | ||
701 | if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) { | 701 | if (svd[0].sd_want == W_EXIT && svd[0].state == S_DOWN) { |
702 | if (svd[1].pid == 0) | 702 | if (svd[1].pid == 0) |
703 | _exit(EXIT_SUCCESS); | 703 | _exit_SUCCESS(); |
704 | if (svd[1].sd_want != W_EXIT) { | 704 | if (svd[1].sd_want != W_EXIT) { |
705 | svd[1].sd_want = W_EXIT; | 705 | svd[1].sd_want = W_EXIT; |
706 | /* stopservice(&svd[1]); */ | 706 | /* stopservice(&svd[1]); */ |
diff --git a/scripts/bb_release b/scripts/bb_release index 545440d3a..180ad8f2e 100755 --- a/scripts/bb_release +++ b/scripts/bb_release | |||
@@ -17,7 +17,7 @@ VERSION=`ls busybox-*.tar.gz | sed 's/busybox-\(.*\)\.tar\.gz/\1/'` | |||
17 | zcat busybox-$VERSION.tar.gz | bzip2 > busybox-$VERSION.tar.bz2 | 17 | zcat busybox-$VERSION.tar.gz | bzip2 > busybox-$VERSION.tar.bz2 |
18 | 18 | ||
19 | for releasefile in busybox-$VERSION.tar.gz busybox-$VERSION.tar.bz2; do | 19 | for releasefile in busybox-$VERSION.tar.gz busybox-$VERSION.tar.bz2; do |
20 | test -f $releasefile || { echo "no $releasefile"; exit 1; } | 20 | test -f $releasefile || { echo "no $releasefile"; exit 1; } |
21 | gpg --detach-sign $releasefile | 21 | gpg --detach-sign $releasefile |
22 | sha256sum $releasefile > $releasefile.sha256 | 22 | sha256sum $releasefile > $releasefile.sha256 |
23 | done | 23 | done |
diff --git a/scripts/echo.c b/scripts/echo.c index 7474ccdd4..e3a07adf0 100644 --- a/scripts/echo.c +++ b/scripts/echo.c | |||
@@ -153,25 +153,32 @@ int main(int argc, char **argv) | |||
153 | if (!eflag) { | 153 | if (!eflag) { |
154 | /* optimization for very common case */ | 154 | /* optimization for very common case */ |
155 | fputs(arg, stdout); | 155 | fputs(arg, stdout); |
156 | } else while ((c = *arg++)) { | 156 | } else |
157 | if (c == eflag) { /* Check for escape seq. */ | 157 | while ((c = *arg++) != '\0') { |
158 | if (c == eflag) { | ||
159 | /* This is an "\x" sequence */ | ||
160 | |||
158 | if (*arg == 'c') { | 161 | if (*arg == 'c') { |
159 | /* '\c' means cancel newline and | 162 | /* "\c" means cancel newline and |
160 | * ignore all subsequent chars. */ | 163 | * ignore all subsequent chars. */ |
161 | goto ret; | 164 | goto ret; |
162 | } | 165 | } |
163 | { | 166 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals |
164 | /* Since SUSv3 mandates a first digit of 0, 4-digit octals | 167 | * of the form \0### are accepted. */ |
165 | * of the form \0### are accepted. */ | 168 | if (*arg == '0') { |
166 | if (*arg == '0') { | 169 | if ((unsigned char)(arg[1] - '0') < 8) { |
167 | /* NB: don't turn "...\0" into "...\" */ | 170 | /* 2nd char is 0..7: skip leading '0' */ |
168 | if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) { | 171 | arg++; |
169 | arg++; | ||
170 | } | ||
171 | } | 172 | } |
172 | /* bb_process_escape_sequence handles NUL correctly | 173 | } |
173 | * ("...\" case. */ | 174 | /* bb_process_escape_sequence handles NUL correctly |
174 | c = bb_process_escape_sequence(&arg); | 175 | * ("...\" case). */ |
176 | { | ||
177 | /* optimization: don't force arg to be on-stack, | ||
178 | * use another variable for that. ~30 bytes win */ | ||
179 | const char *z = arg; | ||
180 | c = bb_process_escape_sequence(&z); | ||
181 | arg = z; | ||
175 | } | 182 | } |
176 | } | 183 | } |
177 | putchar(c); | 184 | putchar(c); |
diff --git a/scripts/embedded_scripts b/scripts/embedded_scripts index aa7bf3e8a..205ac591a 100755 --- a/scripts/embedded_scripts +++ b/scripts/embedded_scripts | |||
@@ -23,6 +23,12 @@ if test $? != 0; then | |||
23 | exit 1 | 23 | exit 1 |
24 | fi | 24 | fi |
25 | 25 | ||
26 | bzip2 </dev/null >/dev/null | ||
27 | if test $? != 0; then | ||
28 | echo 'bzip2 is not installed' | ||
29 | exit 1 | ||
30 | fi | ||
31 | |||
26 | custom_scripts="" | 32 | custom_scripts="" |
27 | if [ -d "$custom_loc" ] | 33 | if [ -d "$custom_loc" ] |
28 | then | 34 | then |
diff --git a/scripts/mkconfigs b/scripts/mkconfigs index 6a26fe1dd..1bbf10c3a 100755 --- a/scripts/mkconfigs +++ b/scripts/mkconfigs | |||
@@ -28,6 +28,17 @@ | |||
28 | 28 | ||
29 | config=.config | 29 | config=.config |
30 | 30 | ||
31 | od -v -b </dev/null >/dev/null | ||
32 | if test $? != 0; then | ||
33 | echo 'od tool is not installed or cannot accept "-v -b" options' | ||
34 | exit 1 | ||
35 | fi | ||
36 | bzip2 </dev/null >/dev/null | ||
37 | if test $? != 0; then | ||
38 | echo 'bzip2 is not installed' | ||
39 | exit 1 | ||
40 | fi | ||
41 | |||
31 | { | 42 | { |
32 | echo "\ | 43 | echo "\ |
33 | #ifndef _BBCONFIGOPTS_H | 44 | #ifndef _BBCONFIGOPTS_H |
diff --git a/shell/ash.c b/shell/ash.c index ad1e5ba7e..09659c1da 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6132,7 +6132,7 @@ openhere(union node *redir) | |||
6132 | ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); | 6132 | ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); |
6133 | signal(SIGPIPE, SIG_DFL); | 6133 | signal(SIGPIPE, SIG_DFL); |
6134 | xwrite(pip[1], p, len); | 6134 | xwrite(pip[1], p, len); |
6135 | _exit(EXIT_SUCCESS); | 6135 | _exit_SUCCESS(); |
6136 | } | 6136 | } |
6137 | #endif | 6137 | #endif |
6138 | out: | 6138 | out: |
@@ -15860,7 +15860,7 @@ forkshell_openhere(struct forkshell *fs) | |||
15860 | ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); | 15860 | ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); |
15861 | signal(SIGPIPE, SIG_DFL); | 15861 | signal(SIGPIPE, SIG_DFL); |
15862 | xwrite(pip[1], p, len); | 15862 | xwrite(pip[1], p, len); |
15863 | _exit(EXIT_SUCCESS); | 15863 | _exit_SUCCESS(); |
15864 | } | 15864 | } |
15865 | 15865 | ||
15866 | static void | 15866 | static void |
diff --git a/shell/hush.c b/shell/hush.c index 6a27b1634..982fc356a 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -8587,7 +8587,7 @@ static NOINLINE void pseudo_exec_argv(nommu_save_t *nommu_save, | |||
8587 | * expand_assignments(): think about ... | var=`sleep 1` | ... | 8587 | * expand_assignments(): think about ... | var=`sleep 1` | ... |
8588 | */ | 8588 | */ |
8589 | free_strings(new_env); | 8589 | free_strings(new_env); |
8590 | _exit(EXIT_SUCCESS); | 8590 | _exit_SUCCESS(); |
8591 | } | 8591 | } |
8592 | 8592 | ||
8593 | sv_shadowed = G.shadowed_vars_pp; | 8593 | sv_shadowed = G.shadowed_vars_pp; |
@@ -8768,7 +8768,7 @@ static void pseudo_exec(nommu_save_t *nommu_save, | |||
8768 | 8768 | ||
8769 | /* Case when we are here: ... | >file */ | 8769 | /* Case when we are here: ... | >file */ |
8770 | debug_printf_exec("pseudo_exec'ed null command\n"); | 8770 | debug_printf_exec("pseudo_exec'ed null command\n"); |
8771 | _exit(EXIT_SUCCESS); | 8771 | _exit_SUCCESS(); |
8772 | } | 8772 | } |
8773 | 8773 | ||
8774 | #if ENABLE_HUSH_JOB | 8774 | #if ENABLE_HUSH_JOB |
diff --git a/sysklogd/logread.c b/sysklogd/logread.c index d5f8ca0a2..e6cfcf4a7 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c | |||
@@ -226,5 +226,5 @@ int logread_main(int argc UNUSED_PARAM, char **argv) | |||
226 | 226 | ||
227 | /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */ | 227 | /* shmdt(shbuf); - on Linux, shmdt is not mandatory on exit */ |
228 | 228 | ||
229 | fflush_stdout_and_exit(EXIT_SUCCESS); | 229 | fflush_stdout_and_exit_SUCCESS(); |
230 | } | 230 | } |
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 2b78c9b12..e62b839f7 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
@@ -405,6 +405,15 @@ testing "sed ^ OR not^" \ | |||
405 | "" \ | 405 | "" \ |
406 | "abca\n" | 406 | "abca\n" |
407 | 407 | ||
408 | # This only works if file name is exactly the same. | ||
409 | # For example, w FILE; w ./FILE won't work. | ||
410 | testing "sed understands duplicate file name" \ | ||
411 | "sed -n -e '/a/w sed.output' -e '/c/w sed.output' 2>&1 && cat sed.output && rm sed.output" \ | ||
412 | "a\nc\n" \ | ||
413 | "" \ | ||
414 | "a\nb\nc\n" | ||
415 | |||
416 | |||
408 | # testing "description" "commands" "result" "infile" "stdin" | 417 | # testing "description" "commands" "result" "infile" "stdin" |
409 | 418 | ||
410 | exit $FAILCOUNT | 419 | exit $FAILCOUNT |
diff --git a/testsuite/sort.tests b/testsuite/sort.tests index c51a8e475..ff33e21b4 100755 --- a/testsuite/sort.tests +++ b/testsuite/sort.tests | |||
@@ -175,6 +175,48 @@ testing "sort file in place" \ | |||
175 | 111 | 175 | 111 |
176 | " "" | 176 | " "" |
177 | 177 | ||
178 | testing "sort -sr (stable and reverse) does NOT reverse 'stable' ordering" \ | ||
179 | "sort -k2 -r -s input" "\ | ||
180 | b 2 | ||
181 | d 2 | ||
182 | a 1 | ||
183 | c 1 | ||
184 | " "\ | ||
185 | a 1 | ||
186 | b 2 | ||
187 | c 1 | ||
188 | d 2 | ||
189 | " "" | ||
190 | |||
191 | testing "sort -h" \ | ||
192 | "sort -h input" "\ | ||
193 | 3e | ||
194 | 4m | ||
195 | 5y | ||
196 | 1023 | ||
197 | 1024 | ||
198 | 1025 | ||
199 | 3000 | ||
200 | 2K | ||
201 | 3k | ||
202 | 1M | ||
203 | 2E | ||
204 | 1Y | ||
205 | " "\ | ||
206 | 1Y | ||
207 | 5y | ||
208 | 1M | ||
209 | 2E | ||
210 | 3k | ||
211 | 3e | ||
212 | 2K | ||
213 | 4m | ||
214 | 1023 | ||
215 | 1025 | ||
216 | 3000 | ||
217 | 1024 | ||
218 | " "" | ||
219 | |||
178 | # testing "description" "command(s)" "result" "infile" "stdin" | 220 | # testing "description" "command(s)" "result" "infile" "stdin" |
179 | 221 | ||
180 | exit $FAILCOUNT | 222 | exit $FAILCOUNT |
diff --git a/util-linux/cal.c b/util-linux/cal.c index 6ba6ebf98..522ab3476 100644 --- a/util-linux/cal.c +++ b/util-linux/cal.c | |||
@@ -233,7 +233,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv) | |||
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | fflush_stdout_and_exit(EXIT_SUCCESS); | 236 | fflush_stdout_and_exit_SUCCESS(); |
237 | } | 237 | } |
238 | 238 | ||
239 | /* | 239 | /* |
diff --git a/util-linux/chrt.c b/util-linux/chrt.c index 6799abb2d..be96fa426 100644 --- a/util-linux/chrt.c +++ b/util-linux/chrt.c | |||
@@ -110,7 +110,7 @@ int chrt_main(int argc UNUSED_PARAM, char **argv) | |||
110 | show_min_max(SCHED_RR); | 110 | show_min_max(SCHED_RR); |
111 | show_min_max(SCHED_BATCH); | 111 | show_min_max(SCHED_BATCH); |
112 | show_min_max(SCHED_IDLE); | 112 | show_min_max(SCHED_IDLE); |
113 | fflush_stdout_and_exit(EXIT_SUCCESS); | 113 | fflush_stdout_and_exit_SUCCESS(); |
114 | } | 114 | } |
115 | //if (opt & OPT_r) | 115 | //if (opt & OPT_r) |
116 | // policy = SCHED_RR; - default, already set | 116 | // policy = SCHED_RR; - default, already set |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 1c2a7d683..9c393b8fc 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -665,7 +665,7 @@ read_line(const char *prompt) | |||
665 | 665 | ||
666 | sz = read_line_input(NULL, prompt, line_buffer, sizeof(line_buffer)); | 666 | sz = read_line_input(NULL, prompt, line_buffer, sizeof(line_buffer)); |
667 | if (sz <= 0) | 667 | if (sz <= 0) |
668 | exit(EXIT_SUCCESS); /* Ctrl-D or Ctrl-C */ | 668 | exit_SUCCESS(); /* Ctrl-D or Ctrl-C */ |
669 | 669 | ||
670 | if (line_buffer[sz-1] == '\n') | 670 | if (line_buffer[sz-1] == '\n') |
671 | line_buffer[--sz] = '\0'; | 671 | line_buffer[--sz] = '\0'; |
@@ -2855,7 +2855,7 @@ xselect(void) | |||
2855 | if (ENABLE_FEATURE_CLEAN_UP) | 2855 | if (ENABLE_FEATURE_CLEAN_UP) |
2856 | close_dev_fd(); | 2856 | close_dev_fd(); |
2857 | bb_putchar('\n'); | 2857 | bb_putchar('\n'); |
2858 | exit(EXIT_SUCCESS); | 2858 | exit_SUCCESS(); |
2859 | case 'r': | 2859 | case 'r': |
2860 | return; | 2860 | return; |
2861 | case 's': | 2861 | case 's': |
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 765740ff1..6c66c130d 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
@@ -383,7 +383,7 @@ bsd_select(void) | |||
383 | 383 | ||
384 | if (xbsd_readlabel(NULL) == 0) | 384 | if (xbsd_readlabel(NULL) == 0) |
385 | if (xbsd_create_disklabel() == 0) | 385 | if (xbsd_create_disklabel() == 0) |
386 | exit(EXIT_SUCCESS); | 386 | exit_SUCCESS(); |
387 | 387 | ||
388 | #endif | 388 | #endif |
389 | 389 | ||
@@ -411,7 +411,7 @@ bsd_select(void) | |||
411 | case 'q': | 411 | case 'q': |
412 | if (ENABLE_FEATURE_CLEAN_UP) | 412 | if (ENABLE_FEATURE_CLEAN_UP) |
413 | close_dev_fd(); | 413 | close_dev_fd(); |
414 | exit(EXIT_SUCCESS); | 414 | exit_SUCCESS(); |
415 | case 'r': | 415 | case 'r': |
416 | return; | 416 | return; |
417 | case 's': | 417 | case 's': |
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 40b86d01b..dd2265c32 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
@@ -423,7 +423,7 @@ static void check_mount(void) | |||
423 | cont = ask("Do you really want to continue", 0); | 423 | cont = ask("Do you really want to continue", 0); |
424 | if (!cont) { | 424 | if (!cont) { |
425 | puts("Check aborted"); | 425 | puts("Check aborted"); |
426 | exit(EXIT_SUCCESS); | 426 | exit_SUCCESS(); |
427 | } | 427 | } |
428 | } | 428 | } |
429 | } | 429 | } |
diff --git a/util-linux/hexdump_xxd.c b/util-linux/hexdump_xxd.c index 76dada983..4372ac770 100644 --- a/util-linux/hexdump_xxd.c +++ b/util-linux/hexdump_xxd.c | |||
@@ -150,7 +150,7 @@ static void reverse(unsigned opt, const char *filename) | |||
150 | free(buf); | 150 | free(buf); |
151 | } | 151 | } |
152 | //fclose(fp); | 152 | //fclose(fp); |
153 | fflush_stdout_and_exit(EXIT_SUCCESS); | 153 | fflush_stdout_and_exit_SUCCESS(); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void print_C_style(const char *p, const char *hdr) | 156 | static void print_C_style(const char *p, const char *hdr) |
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c index ef2529c05..5973cbf57 100644 --- a/util-linux/ipcs.c +++ b/util-linux/ipcs.c | |||
@@ -600,15 +600,15 @@ int ipcs_main(int argc UNUSED_PARAM, char **argv) | |||
600 | id = xatoi(opt_i); | 600 | id = xatoi(opt_i); |
601 | if (opt & flag_shm) { | 601 | if (opt & flag_shm) { |
602 | print_shm(id); | 602 | print_shm(id); |
603 | fflush_stdout_and_exit(EXIT_SUCCESS); | 603 | fflush_stdout_and_exit_SUCCESS(); |
604 | } | 604 | } |
605 | if (opt & flag_sem) { | 605 | if (opt & flag_sem) { |
606 | print_sem(id); | 606 | print_sem(id); |
607 | fflush_stdout_and_exit(EXIT_SUCCESS); | 607 | fflush_stdout_and_exit_SUCCESS(); |
608 | } | 608 | } |
609 | if (opt & flag_msg) { | 609 | if (opt & flag_msg) { |
610 | print_msg(id); | 610 | print_msg(id); |
611 | fflush_stdout_and_exit(EXIT_SUCCESS); | 611 | fflush_stdout_and_exit_SUCCESS(); |
612 | } | 612 | } |
613 | bb_show_usage(); | 613 | bb_show_usage(); |
614 | } | 614 | } |
@@ -633,5 +633,5 @@ int ipcs_main(int argc UNUSED_PARAM, char **argv) | |||
633 | do_sem(format); | 633 | do_sem(format); |
634 | bb_putchar('\n'); | 634 | bb_putchar('\n'); |
635 | } | 635 | } |
636 | fflush_stdout_and_exit(EXIT_SUCCESS); | 636 | fflush_stdout_and_exit_SUCCESS(); |
637 | } | 637 | } |
diff --git a/util-linux/last.c b/util-linux/last.c index 24ce7a8d8..63751ca45 100644 --- a/util-linux/last.c +++ b/util-linux/last.c | |||
@@ -162,5 +162,5 @@ int last_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
162 | xlseek(file, pos, SEEK_SET); | 162 | xlseek(file, pos, SEEK_SET); |
163 | } | 163 | } |
164 | 164 | ||
165 | fflush_stdout_and_exit(EXIT_SUCCESS); | 165 | fflush_stdout_and_exit_SUCCESS(); |
166 | } | 166 | } |
diff --git a/util-linux/last_fancy.c b/util-linux/last_fancy.c index e56e0ba85..648236229 100644 --- a/util-linux/last_fancy.c +++ b/util-linux/last_fancy.c | |||
@@ -296,5 +296,5 @@ int last_main(int argc UNUSED_PARAM, char **argv) | |||
296 | 296 | ||
297 | if (ENABLE_FEATURE_CLEAN_UP) | 297 | if (ENABLE_FEATURE_CLEAN_UP) |
298 | close(file); | 298 | close(file); |
299 | fflush_stdout_and_exit(EXIT_SUCCESS); | 299 | fflush_stdout_and_exit_SUCCESS(); |
300 | } | 300 | } |