diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/hash_md5_sha.c | 28 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 10 |
2 files changed, 22 insertions, 16 deletions
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 880ffab01..88baf51dc 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
@@ -23,6 +23,14 @@ static void cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) | |||
23 | ); | 23 | ); |
24 | } | 24 | } |
25 | static smallint shaNI; | 25 | static smallint shaNI; |
26 | static int get_shaNI(void) | ||
27 | { | ||
28 | unsigned eax = 7, ebx = ebx, ecx = 0, edx = edx; | ||
29 | cpuid(&eax, &ebx, &ecx, &edx); | ||
30 | ebx = ((ebx >> 28) & 2) - 1; /* bit 29 -> 1 or -1 */ | ||
31 | shaNI = (int)ebx; | ||
32 | return (int)ebx; | ||
33 | } | ||
26 | void FAST_FUNC sha1_process_block64_shaNI(sha1_ctx_t *ctx); | 34 | void FAST_FUNC sha1_process_block64_shaNI(sha1_ctx_t *ctx); |
27 | void FAST_FUNC sha256_process_block64_shaNI(sha256_ctx_t *ctx); | 35 | void FAST_FUNC sha256_process_block64_shaNI(sha256_ctx_t *ctx); |
28 | # if defined(__i386__) | 36 | # if defined(__i386__) |
@@ -1175,12 +1183,10 @@ void FAST_FUNC sha1_begin(sha1_ctx_t *ctx) | |||
1175 | #if ENABLE_SHA1_HWACCEL | 1183 | #if ENABLE_SHA1_HWACCEL |
1176 | # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) | 1184 | # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) |
1177 | { | 1185 | { |
1178 | if (!shaNI) { | 1186 | int ni = shaNI; |
1179 | unsigned eax = 7, ebx = ebx, ecx = 0, edx = edx; | 1187 | if (!ni) |
1180 | cpuid(&eax, &ebx, &ecx, &edx); | 1188 | ni = get_shaNI(); |
1181 | shaNI = ((ebx >> 29) << 1) - 1; | 1189 | if (ni > 0) |
1182 | } | ||
1183 | if (shaNI > 0) | ||
1184 | ctx->process_block = sha1_process_block64_shaNI; | 1190 | ctx->process_block = sha1_process_block64_shaNI; |
1185 | } | 1191 | } |
1186 | # endif | 1192 | # endif |
@@ -1229,12 +1235,10 @@ void FAST_FUNC sha256_begin(sha256_ctx_t *ctx) | |||
1229 | #if ENABLE_SHA256_HWACCEL | 1235 | #if ENABLE_SHA256_HWACCEL |
1230 | # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) | 1236 | # if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) |
1231 | { | 1237 | { |
1232 | if (!shaNI) { | 1238 | int ni = shaNI; |
1233 | unsigned eax = 7, ebx = ebx, ecx = 0, edx = edx; | 1239 | if (!ni) |
1234 | cpuid(&eax, &ebx, &ecx, &edx); | 1240 | ni = get_shaNI(); |
1235 | shaNI = ((ebx >> 29) << 1) - 1; | 1241 | if (ni > 0) |
1236 | } | ||
1237 | if (shaNI > 0) | ||
1238 | ctx->process_block = sha256_process_block64_shaNI; | 1242 | ctx->process_block = sha256_process_block64_shaNI; |
1239 | } | 1243 | } |
1240 | # endif | 1244 | # endif |
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 62beb6a5d..3845c0892 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -273,10 +273,12 @@ pid_t FAST_FUNC fork_or_rexec(char **argv) | |||
273 | /* fflush_all(); ? - so far all callers had no buffered output to flush */ | 273 | /* fflush_all(); ? - so far all callers had no buffered output to flush */ |
274 | 274 | ||
275 | pid = xvfork(); | 275 | pid = xvfork(); |
276 | if (pid) /* parent */ | 276 | if (pid == 0) /* child - re-exec ourself */ |
277 | return pid; | 277 | re_exec(argv); /* NORETURN */ |
278 | /* child - re-exec ourself */ | 278 | |
279 | re_exec(argv); | 279 | /* parent */ |
280 | argv[0][0] &= 0x7f; /* undo re_rexec() damage */ | ||
281 | return pid; | ||
280 | } | 282 | } |
281 | #endif | 283 | #endif |
282 | 284 | ||