Commit 14386add authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Fix my_hrtime() on Windows to return microseconds since Unix epoch.

Prior to this patch it returned microseconds since 1 Jan 1601 (Windows epoch)
parent 40b6eb9f
......@@ -26,6 +26,7 @@
#include <nks/time.h>
#elif defined(__WIN__)
static ulonglong query_performance_frequency, query_performance_offset;
#define OFFSET_TO_EPOC 116444736000000000LL
#elif defined(HAVE_GETHRTIME)
static ulonglong gethrtime_offset;
#endif
......@@ -81,6 +82,7 @@ my_hrtime_t my_hrtime()
#if defined(__WIN__)
ulonglong newtime;
GetSystemTimeAsFileTime((FILETIME*)&newtime);
newtime -= OFFSET_TO_EPOC;
hrtime.val= newtime/10;
#elif defined(HAVE_GETHRTIME)
struct timeval t;
......@@ -117,7 +119,6 @@ void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp)
void my_time_init()
{
#ifdef __WIN__
#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
FILETIME ft;
LARGE_INTEGER li, t_cnt;
DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
......
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