summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-04-19 19:28:23 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2011-04-19 19:28:23 +0200
commit5346cb8d2745acd660b301092458e231c9f53319 (patch)
tree81378efa78796b3ad55e8c7cf35fb6d3a861066c /mysys
parenta7ff7918a055a8dbae10c59279b2d9ee7f5c07e0 (diff)
downloadmariadb-git-5346cb8d2745acd660b301092458e231c9f53319.tar.gz
Fix my_hrtime() on Windows to return microseconds since Unix epoch.
Prior to this patch it returned microseconds since 1 Jan 1601 (Windows epoch)
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_getsystime.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index 2b91c9d6b8c..125d389f3d5 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -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));