Commit 269e95e4 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

port perfnotes to windows. addresses #1246

git-svn-id: file:///svn/toku/tokudb.1032b@8073 c7de825b-a66e-492c-adef-691d508d4ae1
parent 236adb1b
#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(struct timespec *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, struct timespec *ts) {
if (clockid == CLOCK_REALTIME)
return clock_get_realtime(ts);
else
return -1;
}
......@@ -15,6 +15,17 @@ struct timezone {
int gettimeofday(struct timeval *tv, struct timezone *tz);
typedef enum {
CLOCK_REALTIME = 0
} clockid_t;
struct timespec {
long tv_sec;
long tv_nsec;
};
int clock_gettime(clockid_t clock_id, struct timespec *ts);
#ifdef __cplusplus
};
#endif
......
......@@ -222,26 +222,6 @@ toku_os_gettid(void) {
return GetCurrentThreadId();
}
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;
if (tv) {
tv->tv_sec = t.QuadPart / 1000000;
tv->tv_usec = t.QuadPart % 1000000;
}
if (tz) {
assert(0);
}
return 0;
}
int
toku_os_lock_file(char *name) {
int fd = _sopen(name, O_CREAT, _SH_DENYRW, S_IREAD|S_IWRITE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment