diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | apps/openssl/apps_win.c | 66 | ||||
-rw-r--r-- | m4/check-os-options.m4 | 2 | ||||
-rw-r--r-- | patches/speed.c.patch | 99 |
4 files changed, 167 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 91a2703..66ac3b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -107,7 +107,7 @@ if(WIN32) | |||
107 | add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) | 107 | add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) |
108 | add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS) | 108 | add_definitions(-D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS) |
109 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) | 109 | add_definitions(-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600) |
110 | add_definitions(-DCPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG -DNO_CRYPT) | 110 | add_definitions(-DCPPFLAGS -DNO_SYSLOG -DNO_CRYPT) |
111 | set(PLATFORM_LIBS ${PLATFORM_LIBS} ws2_32) | 111 | set(PLATFORM_LIBS ${PLATFORM_LIBS} ws2_32) |
112 | endif() | 112 | endif() |
113 | 113 | ||
diff --git a/apps/openssl/apps_win.c b/apps/openssl/apps_win.c index 364c033..ba7b1e6 100644 --- a/apps/openssl/apps_win.c +++ b/apps/openssl/apps_win.c | |||
@@ -70,3 +70,69 @@ destroy_ui(void) | |||
70 | ui_method = NULL; | 70 | ui_method = NULL; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | |||
74 | static void (*speed_alarm_handler)(int); | ||
75 | static HANDLE speed_thread; | ||
76 | static unsigned int speed_lapse; | ||
77 | static volatile unsigned int speed_schlock; | ||
78 | |||
79 | void | ||
80 | speed_signal(int sigcatch, void (*func)(int sigraised)) | ||
81 | { | ||
82 | speed_alarm_handler = func; | ||
83 | } | ||
84 | |||
85 | static DWORD WINAPI | ||
86 | speed_timer(VOID * arg) | ||
87 | { | ||
88 | speed_schlock = 1; | ||
89 | Sleep(speed_lapse); | ||
90 | (*speed_alarm_handler)(0); | ||
91 | return (0); | ||
92 | } | ||
93 | |||
94 | unsigned int | ||
95 | speed_alarm(unsigned int seconds) | ||
96 | { | ||
97 | DWORD err; | ||
98 | |||
99 | speed_lapse = seconds * 1000; | ||
100 | speed_schlock = 0; | ||
101 | |||
102 | speed_thread = CreateThread(NULL, 4096, speed_timer, NULL, 0, NULL); | ||
103 | if (speed_thread == NULL) { | ||
104 | err = GetLastError(); | ||
105 | BIO_printf(bio_err, "CreateThread failed (%lu)", err); | ||
106 | ExitProcess(err); | ||
107 | } | ||
108 | |||
109 | while (!speed_schlock) | ||
110 | Sleep(0); | ||
111 | |||
112 | return (seconds); | ||
113 | } | ||
114 | |||
115 | void | ||
116 | speed_alarm_free(int run) | ||
117 | { | ||
118 | DWORD err; | ||
119 | |||
120 | if (run) { | ||
121 | if (TerminateThread(speed_thread, 0) == 0) { | ||
122 | err = GetLastError(); | ||
123 | BIO_printf(bio_err, "TerminateThread failed (%lu)", | ||
124 | err); | ||
125 | ExitProcess(err); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | if (CloseHandle(speed_thread) == 0) { | ||
130 | err = GetLastError(); | ||
131 | BIO_printf(bio_err, "CloseHandle failed (%lu)", err); | ||
132 | ExitProcess(err); | ||
133 | } | ||
134 | |||
135 | speed_thread = NULL; | ||
136 | speed_lapse = 0; | ||
137 | speed_schlock = 0; | ||
138 | } | ||
diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4 index c88c259..6483c89 100644 --- a/m4/check-os-options.m4 +++ b/m4/check-os-options.m4 | |||
@@ -107,7 +107,7 @@ char buf[1]; getentropy(buf, 1); | |||
107 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" | 107 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" |
108 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" | 108 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" |
109 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600" | 109 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600" |
110 | CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_SPEED" | 110 | CPPFLAGS="$CPPFLAGS" |
111 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) | 111 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) |
112 | ;; | 112 | ;; |
113 | *solaris*) | 113 | *solaris*) |
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 | ||