diff options
Diffstat (limited to 'crypto/compat/posix_win.c')
-rw-r--r-- | crypto/compat/posix_win.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index 855406b..f8a46ab 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
@@ -166,3 +166,27 @@ posix_setsockopt(int sockfd, int level, int optname, | |||
166 | int rc = setsockopt(sockfd, level, optname, (char *)optval, optlen); | 166 | int rc = setsockopt(sockfd, level, optname, (char *)optval, optlen); |
167 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); | 167 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); |
168 | } | 168 | } |
169 | |||
170 | #ifdef _MSC_VER | ||
171 | int gettimeofday(struct timeval * tp, struct timezone * tzp) | ||
172 | { | ||
173 | /* | ||
174 | * Note: some broken versions only have 8 trailing zero's, the correct | ||
175 | * epoch has 9 trailing zero's | ||
176 | */ | ||
177 | static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); | ||
178 | |||
179 | SYSTEMTIME system_time; | ||
180 | FILETIME file_time; | ||
181 | uint64_t time; | ||
182 | |||
183 | GetSystemTime(&system_time); | ||
184 | SystemTimeToFileTime(&system_time, &file_time); | ||
185 | time = ((uint64_t)file_time.dwLowDateTime); | ||
186 | time += ((uint64_t)file_time.dwHighDateTime) << 32; | ||
187 | |||
188 | tp->tv_sec = (long)((time - EPOCH) / 10000000L); | ||
189 | tp->tv_usec = (long)(system_time.wMilliseconds * 1000); | ||
190 | return 0; | ||
191 | } | ||
192 | #endif | ||