diff options
Diffstat (limited to 'libbb/hash_md5_sha.c')
-rw-r--r-- | libbb/hash_md5_sha.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 053ebe291..faf485df5 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
@@ -509,6 +509,27 @@ static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | |||
509 | d = ctx->hash[3]; | 509 | d = ctx->hash[3]; |
510 | e = ctx->hash[4]; | 510 | e = ctx->hash[4]; |
511 | 511 | ||
512 | /* From kernel source comments: | ||
513 | * """ | ||
514 | * If you have 32 registers or more, the compiler can (and should) | ||
515 | * try to change the array[] accesses into registers. However, on | ||
516 | * machines with less than ~25 registers, that won't really work, | ||
517 | * and at least gcc will make an unholy mess of it. | ||
518 | * | ||
519 | * So to avoid that mess which just slows things down, we force | ||
520 | * the stores to memory to actually happen (we might be better off | ||
521 | * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as | ||
522 | * suggested by Artur Skawina - that will also make gcc unable to | ||
523 | * try to do the silly "optimize away loads" part because it won't | ||
524 | * see what the value will be). | ||
525 | * """ | ||
526 | */ | ||
527 | #if defined(__i386__) | ||
528 | # define DO_NOT_TRY_PROPAGATING(m) asm("":"+m"(m)) | ||
529 | #else | ||
530 | # define DO_NOT_TRY_PROPAGATING(m) ((void)0) | ||
531 | #endif | ||
532 | |||
512 | #undef OP | 533 | #undef OP |
513 | #define OP(A,B,C,D,E, n) \ | 534 | #define OP(A,B,C,D,E, n) \ |
514 | do { \ | 535 | do { \ |
@@ -517,6 +538,7 @@ static void FAST_FUNC sha1_process_block64(sha1_ctx_t *ctx) | |||
517 | work += W[n & 15] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[n]); \ | 538 | work += W[n & 15] = SWAP_BE32(((uint32_t*)ctx->wbuffer)[n]); \ |
518 | if (n >= 16) \ | 539 | if (n >= 16) \ |
519 | work += W[n & 15] = rotl32(W[(n+13) & 15] ^ W[(n+8) & 15] ^ W[(n+2) & 15] ^ W[n & 15], 1); \ | 540 | work += W[n & 15] = rotl32(W[(n+13) & 15] ^ W[(n+8) & 15] ^ W[(n+2) & 15] ^ W[n & 15], 1); \ |
541 | DO_NOT_TRY_PROPAGATING(W[n & 15]); \ | ||
520 | E += work + rotl32(A, 5) + rconsts[n / 20]; \ | 542 | E += work + rotl32(A, 5) + rconsts[n / 20]; \ |
521 | B = rotl32(B, 30); \ | 543 | B = rotl32(B, 30); \ |
522 | } while (0) | 544 | } while (0) |