diff options
author | kinichiro <kinichiro.inoguchi@gmail.com> | 2019-07-14 18:37:59 +0900 |
---|---|---|
committer | kinichiro <kinichiro.inoguchi@gmail.com> | 2019-07-14 19:45:34 +0900 |
commit | 30e91bc6d2b6249da1c8c40582c63601a4838efc (patch) | |
tree | d2fd609548d6eaf47c3751da052367cc433e708b /patches | |
parent | 9e5a54ac9221c906c13a34722811884c0179adc1 (diff) | |
download | portable-30e91bc6d2b6249da1c8c40582c63601a4838efc.tar.gz portable-30e91bc6d2b6249da1c8c40582c63601a4838efc.tar.bz2 portable-30e91bc6d2b6249da1c8c40582c63601a4838efc.zip |
Enable speed on win32
- Use thread and sleep instead of signal and alarm, on win32
- Disable -multi option on win32 since fork is hard to implement
Diffstat (limited to 'patches')
-rw-r--r-- | patches/speed.c.patch | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/patches/speed.c.patch b/patches/speed.c.patch new file mode 100644 index 0000000..28b060b --- /dev/null +++ b/patches/speed.c.patch | |||
@@ -0,0 +1,99 @@ | |||
1 | --- apps/openssl/speed.c.orig Tue Jul 2 21:58:28 2019 | ||
2 | +++ apps/openssl/speed.c Sun Jul 14 19:39:44 2019 | ||
3 | @@ -159,7 +159,16 @@ static void | ||
4 | pkey_print_message(const char *str, const char *str2, | ||
5 | long num, int bits, int sec); | ||
6 | static void print_result(int alg, int run_no, int count, double time_used); | ||
7 | +#ifndef _WIN32 | ||
8 | static int do_multi(int multi); | ||
9 | +#else | ||
10 | +void speed_signal(int sigcatch, void (*func)(int sigraised)); | ||
11 | +unsigned int speed_alarm(unsigned int seconds); | ||
12 | +void speed_alarm_free(int run); | ||
13 | +#define SIGALRM 14 | ||
14 | +#define signal(sigcatch, func) speed_signal((sigcatch), (func)) | ||
15 | +#define alarm(seconds) speed_alarm((seconds)) | ||
16 | +#endif | ||
17 | |||
18 | #define ALGOR_NUM 32 | ||
19 | #define SIZE_NUM 5 | ||
20 | @@ -466,8 +475,10 @@ speed_main(int argc, char **argv) | ||
21 | const EVP_CIPHER *evp_cipher = NULL; | ||
22 | const EVP_MD *evp_md = NULL; | ||
23 | int decrypt = 0; | ||
24 | +#ifndef _WIN32 | ||
25 | int multi = 0; | ||
26 | const char *errstr = NULL; | ||
27 | +#endif | ||
28 | |||
29 | if (single_execution) { | ||
30 | if (pledge("stdio proc", NULL) == -1) { | ||
31 | @@ -544,6 +555,7 @@ speed_main(int argc, char **argv) | ||
32 | j--; /* Otherwise, -decrypt gets confused with an | ||
33 | * algorithm. */ | ||
34 | } | ||
35 | +#ifndef _WIN32 | ||
36 | else if ((argc > 0) && (strcmp(*argv, "-multi") == 0)) { | ||
37 | argc--; | ||
38 | argv++; | ||
39 | @@ -559,6 +571,7 @@ speed_main(int argc, char **argv) | ||
40 | j--; /* Otherwise, -multi gets confused with an | ||
41 | * algorithm. */ | ||
42 | } | ||
43 | +#endif | ||
44 | else if (argc > 0 && !strcmp(*argv, "-mr")) { | ||
45 | mr = 1; | ||
46 | j--; /* Otherwise, -mr gets confused with an | ||
47 | @@ -921,7 +934,9 @@ speed_main(int argc, char **argv) | ||
48 | BIO_printf(bio_err, "-evp e use EVP e.\n"); | ||
49 | BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n"); | ||
50 | BIO_printf(bio_err, "-mr produce machine readable output.\n"); | ||
51 | +#ifndef _WIN32 | ||
52 | BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n"); | ||
53 | +#endif | ||
54 | goto end; | ||
55 | } | ||
56 | argc--; | ||
57 | @@ -929,8 +944,10 @@ speed_main(int argc, char **argv) | ||
58 | j++; | ||
59 | } | ||
60 | |||
61 | +#ifndef _WIN32 | ||
62 | if (multi && do_multi(multi)) | ||
63 | goto show_res; | ||
64 | +#endif | ||
65 | |||
66 | if (j == 0) { | ||
67 | for (i = 0; i < ALGOR_NUM; i++) { | ||
68 | @@ -1771,7 +1788,9 @@ speed_main(int argc, char **argv) | ||
69 | ecdh_doit[j] = 0; | ||
70 | } | ||
71 | } | ||
72 | +#ifndef _WIN32 | ||
73 | show_res: | ||
74 | +#endif | ||
75 | if (!mr) { | ||
76 | fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_VERSION)); | ||
77 | fprintf(stdout, "%s\n", SSLeay_version(SSLEAY_BUILT_ON)); | ||
78 | @@ -1944,11 +1963,15 @@ pkey_print_message(const char *str, const char *str2, | ||
79 | static void | ||
80 | print_result(int alg, int run_no, int count, double time_used) | ||
81 | { | ||
82 | +#ifdef _WIN32 | ||
83 | + speed_alarm_free(run); | ||
84 | +#endif | ||
85 | BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n" | ||
86 | : "%d %s's in %.2fs\n", count, names[alg], time_used); | ||
87 | results[alg][run_no] = ((double) count) / time_used * lengths[run_no]; | ||
88 | } | ||
89 | |||
90 | +#ifndef _WIN32 | ||
91 | static char * | ||
92 | sstrsep(char **string, const char *delim) | ||
93 | { | ||
94 | @@ -2155,4 +2178,5 @@ do_multi(int multi) | ||
95 | free(fds); | ||
96 | return 1; | ||
97 | } | ||
98 | +#endif | ||
99 | #endif | ||