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
This commit is contained in:
Brent Cook 2015-10-18 09:28:10 -05:00
parent c8918dd0be
commit 0197a58969
9 changed files with 34 additions and 13 deletions

2
.gitignore vendored
View File

@ -115,6 +115,8 @@ include/openssl/*.h
/apps/nc/*.h
/apps/nc/*.c
/apps/nc/nc*
!/apps/openssl/apps_win.c
!/apps/openssl/certhash_win.c
/apps/openssl/*.h
/apps/openssl/*.c
/apps/openssl/*.cnf

View File

@ -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()

View File

@ -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

View File

@ -10,7 +10,7 @@
#include <io.h>
#include <fcntl.h>
#include <apps.h>
#include "apps.h"
double
app_tminterval(int stop, int usertime)

View File

@ -188,6 +188,18 @@ static int __secs_to_tm(long long t, struct tm *tm)
return 0;
}
#ifdef _WIN32
struct tm *__gmtime_r(const time_t *t, struct tm *tm)
{
if (__secs_to_tm(*t, tm) < 0) {
errno = EOVERFLOW;
return 0;
}
tm->tm_isdst = 0;
return tm;
}
#endif
time_t timegm(struct tm *tm)
{
struct tm new;

View File

@ -9,11 +9,15 @@
#else
#include <../include/time.h>
#endif
#define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL)
#else
#include_next <time.h>
#endif
#ifdef _WIN32
struct tm *__gmtime_r(const time_t * t, struct tm * tm);
#define gmtime_r(tp, tm) __gmtime_r(tp, tm)
#endif
#ifndef HAVE_TIMEGM
time_t timegm(struct tm *tm);
#endif

View File

@ -11,14 +11,19 @@
#ifdef _WIN32
#include <ws2tcpip.h>
#define SHUT_RDWR SD_BOTH
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#include <errno.h>
#include <unistd.h>
#ifndef SHUT_RDWR
#define SHUT_RDWR SD_BOTH
#endif
#ifndef SHUT_RD
#define SHUT_RD SD_RECEIVE
#endif
#ifndef SHUT_WR
#define SHUT_WR SD_SEND
#endif
int posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
int posix_close(int fd);

View File

@ -223,7 +223,6 @@ done
# copy openssl(1) source
echo "copying openssl(1) source"
$CP $app_src/openssl/openssl.1 apps/openssl
rm -f apps/openssl/*.c apps/openssl/*.h
$CP_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat
$CP $libcrypto_src/cert.pem apps/openssl
$CP $libcrypto_src/openssl.cnf apps/openssl