summaryrefslogtreecommitdiff
path: root/storage/xtradb/ut
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-04-26 14:13:58 +0200
committerSergei Golubchik <serg@mariadb.org>2018-04-26 14:13:58 +0200
commitc74848ba141a813c8cf9a88c5e9c3cb0278d1a3b (patch)
tree103d8bc0c0bcd7bfdeca6a333c50574249c30cb5 /storage/xtradb/ut
parent584137879f00c4d532b1b2b76f754af3061017be (diff)
parent6b84fdb2f32e52299809c0bb771dfeefdb17be03 (diff)
downloadmariadb-git-c74848ba141a813c8cf9a88c5e9c3cb0278d1a3b.tar.gz
Merge branch 'merge-xtradb-5.6' into 10.0
Diffstat (limited to 'storage/xtradb/ut')
-rw-r--r--storage/xtradb/ut/ut0ut.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc
index 3de3d6e5ee6..17caaf4eab6 100644
--- a/storage/xtradb/ut/ut0ut.cc
+++ b/storage/xtradb/ut/ut0ut.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2017, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -50,6 +50,10 @@ Created 5/11/1994 Heikki Tuuri
UNIV_INTERN ibool ut_always_false = FALSE;
#ifdef __WIN__
+#include <innodb_priv.h> /* For sql_print_error */
+typedef VOID(WINAPI *time_fn)(LPFILETIME);
+static time_fn ut_get_system_time_as_file_time = GetSystemTimeAsFileTime;
+
/*****************************************************************//**
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
epoch starts from 1970/1/1. For selection of constant see:
@@ -57,6 +61,28 @@ http://support.microsoft.com/kb/167296/ */
#define WIN_TO_UNIX_DELTA_USEC ((ib_int64_t) 11644473600000000ULL)
+/**
+Initialise highest available time resolution API on Windows
+@return 0 if all OK else -1 */
+int
+ut_win_init_time()
+{
+ HMODULE h = LoadLibrary("kernel32.dll");
+ if (h != NULL)
+ {
+ time_fn pfn = (time_fn)GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
+ if (pfn != NULL)
+ {
+ ut_get_system_time_as_file_time = pfn;
+ }
+ return false;
+ }
+ DWORD error = GetLastError();
+ sql_print_error(
+ "LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu", error);
+ return(-1);
+}
+
/*****************************************************************//**
This is the Windows version of gettimeofday(2).
@return 0 if all OK else -1 */
@@ -75,7 +101,7 @@ ut_gettimeofday(
return(-1);
}
- GetSystemTimeAsFileTime(&ft);
+ ut_get_system_time_as_file_time(&ft);
tm = (ib_int64_t) ft.dwHighDateTime << 32;
tm |= ft.dwLowDateTime;