From 0197a589691274055e3a6f47a3652a6714d676bc Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 18 Oct 2015 09:28:10 -0500 Subject: Windows compatibility fixes VS2013 has trouble with relative include paths for apps/openssl, so move certhash_win/apps_win.c back to apps/openssl. gmtime_r on mingw64 fails with negative time_t, override gmtime_s fails all of the time unit tests, override SHUT_RD/WR are defined in newer mingw64 headers, check before overriding --- apps/CMakeLists.txt | 5 ++-- apps/openssl/Makefile.am | 4 +-- apps/openssl/apps_win.c | 60 ++++++++++++++++++++++++++++++++++++++ apps/openssl/certhash_win.c | 13 +++++++++ apps/openssl/compat/apps_win.c | 60 -------------------------------------- apps/openssl/compat/certhash_win.c | 13 --------- 6 files changed, 77 insertions(+), 78 deletions(-) create mode 100644 apps/openssl/apps_win.c create mode 100644 apps/openssl/certhash_win.c delete mode 100644 apps/openssl/compat/apps_win.c delete mode 100644 apps/openssl/compat/certhash_win.c (limited to 'apps') diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 08bce42..6213aeb 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -2,7 +2,6 @@ include_directories( . ../include ../include/compat - ./openssl ) set( @@ -63,8 +62,8 @@ if(CMAKE_HOST_UNIX) endif() if(CMAKE_HOST_WIN32) - set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/apps_win.c) - set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/certhash_win.c) + set(OPENSSL_SRC ${OPENSSL_SRC} openssl/apps_win.c) + set(OPENSSL_SRC ${OPENSSL_SRC} openssl/certhash_win.c) set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/poll_win.c) endif() diff --git a/apps/openssl/Makefile.am b/apps/openssl/Makefile.am index 5a8d458..6ec3d62 100644 --- a/apps/openssl/Makefile.am +++ b/apps/openssl/Makefile.am @@ -60,11 +60,11 @@ openssl_SOURCES += x509.c if BUILD_CERTHASH openssl_SOURCES += certhash.c else -openssl_SOURCES += compat/certhash_win.c +openssl_SOURCES += certhash_win.c endif if HOST_WIN -openssl_SOURCES += compat/apps_win.c +openssl_SOURCES += apps_win.c else openssl_SOURCES += apps_posix.c endif diff --git a/apps/openssl/apps_win.c b/apps/openssl/apps_win.c new file mode 100644 index 0000000..37bfcc9 --- /dev/null +++ b/apps/openssl/apps_win.c @@ -0,0 +1,60 @@ +/* + * Public domain + * + * Dongsheng Song + * Brent Cook + */ + +#include + +#include +#include + +#include "apps.h" + +double +app_tminterval(int stop, int usertime) +{ + static unsigned __int64 tmstart; + union { + unsigned __int64 u64; + FILETIME ft; + } ct, et, kt, ut; + + GetProcessTimes(GetCurrentProcess(), &ct.ft, &et.ft, &kt.ft, &ut.ft); + + if (stop == TM_START) { + tmstart = ut.u64 + kt.u64; + } else { + return (ut.u64 + kt.u64 - tmstart) / (double) 10000000; + } + return 0; +} + +int +setup_ui(void) +{ + ui_method = UI_create_method("OpenSSL application user interface"); + UI_method_set_opener(ui_method, ui_open); + UI_method_set_reader(ui_method, ui_read); + UI_method_set_writer(ui_method, ui_write); + UI_method_set_closer(ui_method, ui_close); + + /* + * Set STDIO to binary + */ + _setmode(_fileno(stdin), _O_BINARY); + _setmode(_fileno(stdout), _O_BINARY); + _setmode(_fileno(stderr), _O_BINARY); + + return 0; +} + +void +destroy_ui(void) +{ + if (ui_method) { + UI_destroy_method(ui_method); + ui_method = NULL; + } +} diff --git a/apps/openssl/certhash_win.c b/apps/openssl/certhash_win.c new file mode 100644 index 0000000..be57e2a --- /dev/null +++ b/apps/openssl/certhash_win.c @@ -0,0 +1,13 @@ +/* + * Public domain + * certhash dummy implementation for platforms without symlinks + */ + +#include + +int +certhash_main(int argc, char **argv) +{ + fprintf(stderr, "certhash is not enabled on this platform\n"); + return (1); +} diff --git a/apps/openssl/compat/apps_win.c b/apps/openssl/compat/apps_win.c deleted file mode 100644 index bc999f6..0000000 --- a/apps/openssl/compat/apps_win.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Public domain - * - * Dongsheng Song - * Brent Cook - */ - -#include - -#include -#include - -#include - -double -app_tminterval(int stop, int usertime) -{ - static unsigned __int64 tmstart; - union { - unsigned __int64 u64; - FILETIME ft; - } ct, et, kt, ut; - - GetProcessTimes(GetCurrentProcess(), &ct.ft, &et.ft, &kt.ft, &ut.ft); - - if (stop == TM_START) { - tmstart = ut.u64 + kt.u64; - } else { - return (ut.u64 + kt.u64 - tmstart) / (double) 10000000; - } - return 0; -} - -int -setup_ui(void) -{ - ui_method = UI_create_method("OpenSSL application user interface"); - UI_method_set_opener(ui_method, ui_open); - UI_method_set_reader(ui_method, ui_read); - UI_method_set_writer(ui_method, ui_write); - UI_method_set_closer(ui_method, ui_close); - - /* - * Set STDIO to binary - */ - _setmode(_fileno(stdin), _O_BINARY); - _setmode(_fileno(stdout), _O_BINARY); - _setmode(_fileno(stderr), _O_BINARY); - - return 0; -} - -void -destroy_ui(void) -{ - if (ui_method) { - UI_destroy_method(ui_method); - ui_method = NULL; - } -} diff --git a/apps/openssl/compat/certhash_win.c b/apps/openssl/compat/certhash_win.c deleted file mode 100644 index be57e2a..0000000 --- a/apps/openssl/compat/certhash_win.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Public domain - * certhash dummy implementation for platforms without symlinks - */ - -#include - -int -certhash_main(int argc, char **argv) -{ - fprintf(stderr, "certhash is not enabled on this platform\n"); - return (1); -} -- cgit v1.2.3-55-g6feb