diff options
| author | Brent Cook <bcook@openbsd.org> | 2015-10-18 09:28:10 -0500 |
|---|---|---|
| committer | Brent Cook <bcook@openbsd.org> | 2015-10-18 09:28:10 -0500 |
| commit | 0197a589691274055e3a6f47a3652a6714d676bc (patch) | |
| tree | 9a2c16f2cb86605522ce747c1a71bfd0c23db389 | |
| parent | c8918dd0be1bbadfcebfc6631bd63f3b3e83befd (diff) | |
| download | portable-0197a589691274055e3a6f47a3652a6714d676bc.tar.gz portable-0197a589691274055e3a6f47a3652a6714d676bc.tar.bz2 portable-0197a589691274055e3a6f47a3652a6714d676bc.zip | |
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
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | apps/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | apps/openssl/Makefile.am | 4 | ||||
| -rw-r--r-- | apps/openssl/apps_win.c (renamed from apps/openssl/compat/apps_win.c) | 2 | ||||
| -rw-r--r-- | apps/openssl/certhash_win.c (renamed from apps/openssl/compat/certhash_win.c) | 0 | ||||
| -rw-r--r-- | crypto/compat/timegm.c | 12 | ||||
| -rw-r--r-- | include/compat/time.h | 6 | ||||
| -rw-r--r-- | include/compat/win32netcompat.h | 11 | ||||
| -rwxr-xr-x | update.sh | 1 |
9 files changed, 32 insertions, 11 deletions
| @@ -115,6 +115,8 @@ include/openssl/*.h | |||
| 115 | /apps/nc/*.h | 115 | /apps/nc/*.h |
| 116 | /apps/nc/*.c | 116 | /apps/nc/*.c |
| 117 | /apps/nc/nc* | 117 | /apps/nc/nc* |
| 118 | !/apps/openssl/apps_win.c | ||
| 119 | !/apps/openssl/certhash_win.c | ||
| 118 | /apps/openssl/*.h | 120 | /apps/openssl/*.h |
| 119 | /apps/openssl/*.c | 121 | /apps/openssl/*.c |
| 120 | /apps/openssl/*.cnf | 122 | /apps/openssl/*.cnf |
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( | |||
| 2 | . | 2 | . |
| 3 | ../include | 3 | ../include |
| 4 | ../include/compat | 4 | ../include/compat |
| 5 | ./openssl | ||
| 6 | ) | 5 | ) |
| 7 | 6 | ||
| 8 | set( | 7 | set( |
| @@ -63,8 +62,8 @@ if(CMAKE_HOST_UNIX) | |||
| 63 | endif() | 62 | endif() |
| 64 | 63 | ||
| 65 | if(CMAKE_HOST_WIN32) | 64 | if(CMAKE_HOST_WIN32) |
| 66 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/apps_win.c) | 65 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/apps_win.c) |
| 67 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/certhash_win.c) | 66 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/certhash_win.c) |
| 68 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/poll_win.c) | 67 | set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/poll_win.c) |
| 69 | endif() | 68 | endif() |
| 70 | 69 | ||
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 | |||
| 60 | if BUILD_CERTHASH | 60 | if BUILD_CERTHASH |
| 61 | openssl_SOURCES += certhash.c | 61 | openssl_SOURCES += certhash.c |
| 62 | else | 62 | else |
| 63 | openssl_SOURCES += compat/certhash_win.c | 63 | openssl_SOURCES += certhash_win.c |
| 64 | endif | 64 | endif |
| 65 | 65 | ||
| 66 | if HOST_WIN | 66 | if HOST_WIN |
| 67 | openssl_SOURCES += compat/apps_win.c | 67 | openssl_SOURCES += apps_win.c |
| 68 | else | 68 | else |
| 69 | openssl_SOURCES += apps_posix.c | 69 | openssl_SOURCES += apps_posix.c |
| 70 | endif | 70 | endif |
diff --git a/apps/openssl/compat/apps_win.c b/apps/openssl/apps_win.c index bc999f6..37bfcc9 100644 --- a/apps/openssl/compat/apps_win.c +++ b/apps/openssl/apps_win.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #include <io.h> | 10 | #include <io.h> |
| 11 | #include <fcntl.h> | 11 | #include <fcntl.h> |
| 12 | 12 | ||
| 13 | #include <apps.h> | 13 | #include "apps.h" |
| 14 | 14 | ||
| 15 | double | 15 | double |
| 16 | app_tminterval(int stop, int usertime) | 16 | app_tminterval(int stop, int usertime) |
diff --git a/apps/openssl/compat/certhash_win.c b/apps/openssl/certhash_win.c index be57e2a..be57e2a 100644 --- a/apps/openssl/compat/certhash_win.c +++ b/apps/openssl/certhash_win.c | |||
diff --git a/crypto/compat/timegm.c b/crypto/compat/timegm.c index 0655ce0..5a9e600 100644 --- a/crypto/compat/timegm.c +++ b/crypto/compat/timegm.c | |||
| @@ -188,6 +188,18 @@ static int __secs_to_tm(long long t, struct tm *tm) | |||
| 188 | return 0; | 188 | return 0; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | #ifdef _WIN32 | ||
| 192 | struct tm *__gmtime_r(const time_t *t, struct tm *tm) | ||
| 193 | { | ||
| 194 | if (__secs_to_tm(*t, tm) < 0) { | ||
| 195 | errno = EOVERFLOW; | ||
| 196 | return 0; | ||
| 197 | } | ||
| 198 | tm->tm_isdst = 0; | ||
| 199 | return tm; | ||
| 200 | } | ||
| 201 | #endif | ||
| 202 | |||
| 191 | time_t timegm(struct tm *tm) | 203 | time_t timegm(struct tm *tm) |
| 192 | { | 204 | { |
| 193 | struct tm new; | 205 | struct tm new; |
diff --git a/include/compat/time.h b/include/compat/time.h index 9ed9c03..99a2001 100644 --- a/include/compat/time.h +++ b/include/compat/time.h | |||
| @@ -9,11 +9,15 @@ | |||
| 9 | #else | 9 | #else |
| 10 | #include <../include/time.h> | 10 | #include <../include/time.h> |
| 11 | #endif | 11 | #endif |
| 12 | #define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL) | ||
| 13 | #else | 12 | #else |
| 14 | #include_next <time.h> | 13 | #include_next <time.h> |
| 15 | #endif | 14 | #endif |
| 16 | 15 | ||
| 16 | #ifdef _WIN32 | ||
| 17 | struct tm *__gmtime_r(const time_t * t, struct tm * tm); | ||
| 18 | #define gmtime_r(tp, tm) __gmtime_r(tp, tm) | ||
| 19 | #endif | ||
| 20 | |||
| 17 | #ifndef HAVE_TIMEGM | 21 | #ifndef HAVE_TIMEGM |
| 18 | time_t timegm(struct tm *tm); | 22 | time_t timegm(struct tm *tm); |
| 19 | #endif | 23 | #endif |
diff --git a/include/compat/win32netcompat.h b/include/compat/win32netcompat.h index 452cfba..933f083 100644 --- a/include/compat/win32netcompat.h +++ b/include/compat/win32netcompat.h | |||
| @@ -11,13 +11,18 @@ | |||
| 11 | #ifdef _WIN32 | 11 | #ifdef _WIN32 |
| 12 | 12 | ||
| 13 | #include <ws2tcpip.h> | 13 | #include <ws2tcpip.h> |
| 14 | #include <errno.h> | ||
| 15 | #include <unistd.h> | ||
| 14 | 16 | ||
| 17 | #ifndef SHUT_RDWR | ||
| 15 | #define SHUT_RDWR SD_BOTH | 18 | #define SHUT_RDWR SD_BOTH |
| 19 | #endif | ||
| 20 | #ifndef SHUT_RD | ||
| 16 | #define SHUT_RD SD_RECEIVE | 21 | #define SHUT_RD SD_RECEIVE |
| 22 | #endif | ||
| 23 | #ifndef SHUT_WR | ||
| 17 | #define SHUT_WR SD_SEND | 24 | #define SHUT_WR SD_SEND |
| 18 | 25 | #endif | |
| 19 | #include <errno.h> | ||
| 20 | #include <unistd.h> | ||
| 21 | 26 | ||
| 22 | int posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); | 27 | int posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); |
| 23 | 28 | ||
| @@ -223,7 +223,6 @@ done | |||
| 223 | # copy openssl(1) source | 223 | # copy openssl(1) source |
| 224 | echo "copying openssl(1) source" | 224 | echo "copying openssl(1) source" |
| 225 | $CP $app_src/openssl/openssl.1 apps/openssl | 225 | $CP $app_src/openssl/openssl.1 apps/openssl |
| 226 | rm -f apps/openssl/*.c apps/openssl/*.h | ||
| 227 | $CP_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat | 226 | $CP_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat |
| 228 | $CP $libcrypto_src/cert.pem apps/openssl | 227 | $CP $libcrypto_src/cert.pem apps/openssl |
| 229 | $CP $libcrypto_src/openssl.cnf apps/openssl | 228 | $CP $libcrypto_src/openssl.cnf apps/openssl |
