summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2022-01-08 01:25:23 +0100
committerDenys Vlasenko2022-01-08 01:25:23 +0100
commite7ff29402d23e1c265769dbe809cf2d329a75ec2 (patch)
tree2b8a1ca262efa3de73efb03eef8e75bd112238ed /libbb
parent805ececa615606c02a5ca8f37f84dbbc527221eb (diff)
downloadbusybox-e7ff29402d23e1c265769dbe809cf2d329a75ec2.zip
busybox-e7ff29402d23e1c265769dbe809cf2d329a75ec2.tar.gz
libbb/sha1: simplify cpuid code
function old new delta sha1_begin 107 106 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/hash_md5_sha.c42
1 files changed, 10 insertions, 32 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c
index 0b3af72..a23db51 100644
--- a/libbb/hash_md5_sha.c
+++ b/libbb/hash_md5_sha.c
@@ -1143,43 +1143,21 @@ static void FAST_FUNC sha512_process_block128(sha512_ctx_t *ctx)
#endif /* NEED_SHA512 */
#if ENABLE_SHA1_HWACCEL
-# if defined(__GNUC__) && defined(__i386__)
+# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
{
- asm (
- " cpuid\n"
- : "=a"(*eax), /* Output */
- "=b"(*ebx),
- "=c"(*ecx),
- "=d"(*edx)
- : "0"(*eax), /* Input */
- "1"(*ebx),
- "2"(*ecx),
- "3"(*edx)
- /* No clobbered registers */
+ asm ("cpuid"
+ : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
+ : "0"(*eax), "1"(*ebx), "2"(*ecx), "3"(*edx)
);
}
-struct ASM_expects_76_shaNI { char t[1 - 2*(offsetof(sha1_ctx_t, hash) != 76)]; };
void FAST_FUNC sha1_process_block64_shaNI(sha1_ctx_t *ctx);
-# endif
-# if defined(__GNUC__) && defined(__x86_64__)
-static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
-{
- asm (
- "cpuid\n"
- : "=a"(*eax), /* Output */
- "=b"(*ebx),
- "=c"(*ecx),
- "=d"(*edx)
- : "0"(*eax), /* Input */
- "1"(*ebx),
- "2"(*ecx),
- "3"(*edx)
- /* No clobbered registers */
- );
-}
+# if defined(__i386__)
+struct ASM_expects_76_shaNI { char t[1 - 2*(offsetof(sha1_ctx_t, hash) != 76)]; };
+# endif
+# if defined(__x86_64__)
struct ASM_expects_80_shaNI { char t[1 - 2*(offsetof(sha1_ctx_t, hash) != 80)]; };
-void FAST_FUNC sha1_process_block64_shaNI(sha1_ctx_t *ctx);
+# endif
# endif
#endif
@@ -1199,7 +1177,7 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx)
if (!shaNI) {
unsigned eax = 7, ebx = ebx, ecx = 0, edx = edx;
cpuid(&eax, &ebx, &ecx, &edx);
- shaNI = ((ebx >> 28) & 2) - 1;
+ shaNI = ((ebx >> 29) << 1) - 1;
}
if (shaNI > 0)
ctx->process_block = sha1_process_block64_shaNI;