mirror of
https://github.com/libressl/portable.git
synced 2026-01-17 21:51:17 +01:00
115 lines
3.2 KiB
Diff
115 lines
3.2 KiB
Diff
--- apps/openssl/speed.c.orig Thu Dec 18 07:45:00 2025
|
|
+++ apps/openssl/speed.c Thu Dec 18 07:45:12 2025
|
|
@@ -154,7 +154,16 @@ static void
|
|
pkey_print_message(const char *str, const char *str2,
|
|
int bits, int sec);
|
|
static void print_result(int alg, int run_no, int count, double time_used);
|
|
+#ifndef _WIN32
|
|
static int do_multi(int multi);
|
|
+#else
|
|
+void speed_signal(int sigcatch, void (*func)(int sigraised));
|
|
+unsigned int speed_alarm(unsigned int seconds);
|
|
+void speed_alarm_free(int run);
|
|
+#define SIGALRM 14
|
|
+#define signal(sigcatch, func) speed_signal((sigcatch), (func))
|
|
+#define alarm(seconds) speed_alarm((seconds))
|
|
+#endif
|
|
|
|
#define SIZE_NUM 5
|
|
#define MAX_ECDH_SIZE 256
|
|
@@ -1089,8 +1098,10 @@ speed_main(int argc, char **argv)
|
|
const EVP_CIPHER *evp_cipher = NULL;
|
|
const EVP_MD *evp_md = NULL;
|
|
int decrypt = 0;
|
|
+#ifndef _WIN32
|
|
int multi = 0;
|
|
struct sigaction sa;
|
|
+#endif
|
|
const char *errstr = NULL;
|
|
|
|
if (pledge("stdio proc", NULL) == -1) {
|
|
@@ -1164,6 +1175,7 @@ speed_main(int argc, char **argv)
|
|
decrypt = 1;
|
|
j--; /* Otherwise, -decrypt gets confused with an
|
|
* algorithm. */
|
|
+#ifndef _WIN32
|
|
} else if (argc > 0 && strcmp(*argv, "-multi") == 0) {
|
|
argc--;
|
|
argv++;
|
|
@@ -1178,6 +1190,7 @@ speed_main(int argc, char **argv)
|
|
}
|
|
j--; /* Otherwise, -multi gets confused with an
|
|
* algorithm. */
|
|
+#endif
|
|
} else if (argc > 0 && strcmp(*argv, "-unaligned") == 0) {
|
|
argc--;
|
|
argv++;
|
|
@@ -1492,7 +1505,9 @@ speed_main(int argc, char **argv)
|
|
BIO_printf(bio_err, "-evp e use EVP e.\n");
|
|
BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n");
|
|
BIO_printf(bio_err, "-mr produce machine readable output.\n");
|
|
+#ifndef _WIN32
|
|
BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n");
|
|
+#endif
|
|
BIO_printf(bio_err, "-unaligned n use buffers with offset n from proper alignment.\n");
|
|
goto end;
|
|
}
|
|
@@ -1501,8 +1516,10 @@ speed_main(int argc, char **argv)
|
|
j++;
|
|
}
|
|
|
|
+#ifndef _WIN32
|
|
if (multi && do_multi(multi))
|
|
goto show_res;
|
|
+#endif
|
|
|
|
if (j == 0) {
|
|
for (i = 0; i < ALGOR_NUM; i++) {
|
|
@@ -1573,11 +1590,13 @@ speed_main(int argc, char **argv)
|
|
#define COND (run && count<0x7fffffff)
|
|
#define COUNT(d) (count)
|
|
|
|
+#ifndef _WIN32
|
|
memset(&sa, 0, sizeof(sa));
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = SA_RESTART;
|
|
sa.sa_handler = sig_done;
|
|
sigaction(SIGALRM, &sa, NULL);
|
|
+#endif
|
|
|
|
#ifndef OPENSSL_NO_MD4
|
|
if (doit[D_MD4]) {
|
|
@@ -2362,7 +2381,9 @@ speed_main(int argc, char **argv)
|
|
ecdh_doit[j] = 0;
|
|
}
|
|
}
|
|
+#ifndef _WIN32
|
|
show_res:
|
|
+#endif
|
|
if (!mr) {
|
|
fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION));
|
|
fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON));
|
|
@@ -2518,11 +2539,15 @@ pkey_print_message(const char *str, const char *str2,
|
|
static void
|
|
print_result(int alg, int run_no, int count, double time_used)
|
|
{
|
|
+#ifdef _WIN32
|
|
+ speed_alarm_free(run);
|
|
+#endif
|
|
BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n"
|
|
: "%d %s in %.2fs\n", count, names[alg], time_used);
|
|
results[alg][run_no] = ((double) count) / time_used * lengths[run_no];
|
|
}
|
|
|
|
+#ifndef _WIN32
|
|
static char *
|
|
sstrsep(char **string, const char *delim)
|
|
{
|
|
@@ -2723,5 +2748,6 @@ do_multi(int multi)
|
|
free(fds);
|
|
return 1;
|
|
}
|
|
+#endif
|
|
|
|
#endif /* OPENSSL_NO_SPEED */
|