mariadb/windows/toku_time.c
Yoni Fogel a0d8361575 Closes #1792 closes[t:1792] icc or windows has ctime_r function internally, gives bad warning
Using internal version instead of overwriting

git-svn-id: file:///svn/toku/tokudb@14947 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:58:03 -04:00

49 lines
1.1 KiB
C

#include <windows.h>
#include <assert.h>
#include <toku_time.h>
int
gettimeofday(struct timeval *tv, struct timezone *tz) {
FILETIME ft;
ULARGE_INTEGER t;
GetSystemTimeAsFileTime(&ft);
t.u.LowPart = ft.dwLowDateTime;
t.u.HighPart = ft.dwHighDateTime;
t.QuadPart -= 116444736000000000i64;
t.QuadPart /= 10; // convert to microseconds
if (tv) {
tv->tv_sec = t.QuadPart / 1000000;
tv->tv_usec = t.QuadPart % 1000000;
}
if (tz) {
assert(0);
}
return 0;
}
static int
clock_get_realtime(toku_timespec_t *ts) {
FILETIME ft;
ULARGE_INTEGER t;
GetSystemTimeAsFileTime(&ft);
t.u.LowPart = ft.dwLowDateTime;
t.u.HighPart = ft.dwHighDateTime;
t.QuadPart -= 116444736000000000i64;
t.QuadPart *= 100; // convert to nanoseconds
if (ts) {
ts->tv_sec = t.QuadPart / 1000000000;
ts->tv_nsec = t.QuadPart % 1000000000;
}
return 0;
}
int
clock_gettime(clockid_t clockid, toku_timespec_t *ts) {
if (clockid == CLOCK_REALTIME)
return clock_get_realtime(ts);
else
return -1;
}