add initial CMake and Visual Studio build support

This moves the compatibility include files from include to
include/compat so we can use the awful MS C compiler
<../include/> trick to emulate the GNU #include_next extension.

This also removes a few old compat files we do not need anymore.
This commit is contained in:
Brent Cook
2014-07-10 22:06:10 -05:00
committed by Brent Cook
parent 7a4a37cf59
commit 5d8a1cf715
53 changed files with 2082 additions and 153 deletions

View File

@@ -166,3 +166,27 @@ posix_setsockopt(int sockfd, int level, int optname,
int rc = setsockopt(sockfd, level, optname, (char *)optval, optlen);
return rc == 0 ? 0 : wsa_errno(WSAGetLastError());
}
#ifdef _MSC_VER
int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
/*
* Note: some broken versions only have 8 trailing zero's, the correct
* epoch has 9 trailing zero's
*/
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;
tp->tv_sec = (long)((time - EPOCH) / 10000000L);
tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
return 0;
}
#endif