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:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -115,6 +115,8 @@ include/openssl/*.h | |||||||
| /apps/nc/*.h | /apps/nc/*.h | ||||||
| /apps/nc/*.c | /apps/nc/*.c | ||||||
| /apps/nc/nc* | /apps/nc/nc* | ||||||
|  | !/apps/openssl/apps_win.c | ||||||
|  | !/apps/openssl/certhash_win.c | ||||||
| /apps/openssl/*.h | /apps/openssl/*.h | ||||||
| /apps/openssl/*.c | /apps/openssl/*.c | ||||||
| /apps/openssl/*.cnf | /apps/openssl/*.cnf | ||||||
|   | |||||||
| @@ -2,7 +2,6 @@ include_directories( | |||||||
| 	. | 	. | ||||||
| 	../include | 	../include | ||||||
| 	../include/compat | 	../include/compat | ||||||
| 	./openssl |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| set( | set( | ||||||
| @@ -63,8 +62,8 @@ if(CMAKE_HOST_UNIX) | |||||||
| endif() | endif() | ||||||
|  |  | ||||||
| if(CMAKE_HOST_WIN32) | if(CMAKE_HOST_WIN32) | ||||||
| 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/apps_win.c) | 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/apps_win.c) | ||||||
| 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/certhash_win.c) | 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/certhash_win.c) | ||||||
| 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/poll_win.c) | 	set(OPENSSL_SRC ${OPENSSL_SRC} openssl/compat/poll_win.c) | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -60,11 +60,11 @@ openssl_SOURCES += x509.c | |||||||
| if BUILD_CERTHASH | if BUILD_CERTHASH | ||||||
| openssl_SOURCES += certhash.c | openssl_SOURCES += certhash.c | ||||||
| else | else | ||||||
| openssl_SOURCES += compat/certhash_win.c | openssl_SOURCES += certhash_win.c | ||||||
| endif | endif | ||||||
|  |  | ||||||
| if HOST_WIN | if HOST_WIN | ||||||
| openssl_SOURCES += compat/apps_win.c | openssl_SOURCES += apps_win.c | ||||||
| else | else | ||||||
| openssl_SOURCES += apps_posix.c | openssl_SOURCES += apps_posix.c | ||||||
| endif | endif | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #include <io.h> | #include <io.h> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| 
 | 
 | ||||||
| #include <apps.h> | #include "apps.h" | ||||||
| 
 | 
 | ||||||
| double | double | ||||||
| app_tminterval(int stop, int usertime) | app_tminterval(int stop, int usertime) | ||||||
| @@ -188,6 +188,18 @@ static int __secs_to_tm(long long t, struct tm *tm) | |||||||
| 	return 0; | 	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) | time_t timegm(struct tm *tm) | ||||||
| { | { | ||||||
| 	struct tm new; | 	struct tm new; | ||||||
|   | |||||||
| @@ -9,11 +9,15 @@ | |||||||
| #else | #else | ||||||
| #include <../include/time.h> | #include <../include/time.h> | ||||||
| #endif | #endif | ||||||
| #define gmtime_r(tp, tm) ((gmtime_s((tm), (tp)) == 0) ? (tm) : NULL) |  | ||||||
| #else | #else | ||||||
| #include_next <time.h> | #include_next <time.h> | ||||||
| #endif | #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 | #ifndef HAVE_TIMEGM | ||||||
| time_t timegm(struct tm *tm); | time_t timegm(struct tm *tm); | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -11,14 +11,19 @@ | |||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
|  |  | ||||||
| #include <ws2tcpip.h> | #include <ws2tcpip.h> | ||||||
|  |  | ||||||
| #define SHUT_RDWR SD_BOTH |  | ||||||
| #define SHUT_RD   SD_RECEIVE |  | ||||||
| #define SHUT_WR   SD_SEND |  | ||||||
|  |  | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <unistd.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_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); | ||||||
|  |  | ||||||
| int posix_close(int fd); | int posix_close(int fd); | ||||||
|   | |||||||
| @@ -223,7 +223,6 @@ done | |||||||
| # copy openssl(1) source | # copy openssl(1) source | ||||||
| echo "copying openssl(1) source" | echo "copying openssl(1) source" | ||||||
| $CP $app_src/openssl/openssl.1 apps/openssl | $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_LIBC $libc_src/stdlib/strtonum.c apps/openssl/compat | ||||||
| $CP $libcrypto_src/cert.pem apps/openssl | $CP $libcrypto_src/cert.pem apps/openssl | ||||||
| $CP $libcrypto_src/openssl.cnf apps/openssl | $CP $libcrypto_src/openssl.cnf apps/openssl | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Brent Cook
					Brent Cook