Debian Codegraph @

ext/lsm1/lsm-test/lsmtest_win32.c

raw
1
2 #include "lsmtest.h"
3
4 #ifdef _WIN32
5
6 #define TICKS_PER_SECOND (10000000)
7 #define TICKS_PER_MICROSECOND (10)
8 #define TICKS_UNIX_EPOCH (116444736000000000LL)
9
10 int win32GetTimeOfDay(
11 struct timeval *tp,
12 void *tzp
13 ){
14 FILETIME fileTime;
15 ULONGLONG ticks;
16 ULONGLONG unixTicks;
17
18 unused_parameter(tzp);
19 memset(&fileTime, 0, sizeof(FILETIME));
20 GetSystemTimeAsFileTime(&fileTime);
21 ticks = (ULONGLONG)fileTime.dwHighDateTime << 32;
22 ticks |= (ULONGLONG)fileTime.dwLowDateTime;
23 unixTicks = ticks - TICKS_UNIX_EPOCH;
24 tp->tv_sec = (long)(unixTicks / TICKS_PER_SECOND);
25 unixTicks -= ((ULONGLONG)tp->tv_sec * TICKS_PER_SECOND);
26 tp->tv_usec = (long)(unixTicks / TICKS_PER_MICROSECOND);
27
28 return 0;
29 }
30 #endif