diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-06-21 23:21:22 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2019-06-27 19:19:37 +0200 |
commit | 93942dfe8f3f69c43ef435cf5aacc632090729e8 (patch) | |
tree | f07061690b497a5867c1921931bfa264e314aea5 /mysys/my_getsystime.c | |
parent | 79cd2f5ef12a9879c4d6ae661808d108f5779b6c (diff) | |
download | mariadb-git-93942dfe8f3f69c43ef435cf5aacc632090729e8.tar.gz |
Windows - simplify code in my_getsystime.
Do not load GetSystemTimePreciseAsFileTime() dynamically - it is available
since Windows 8. Win7 is going out of support before 10.5 reaches GA.
Diffstat (limited to 'mysys/my_getsystime.c')
-rw-r--r-- | mysys/my_getsystime.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 677da45ecea..c2aeb40daf0 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -21,10 +21,8 @@ #ifdef _WIN32 #define OFFSET_TO_EPOC 116444736000000000LL static ulonglong query_performance_frequency; -typedef void (WINAPI* get_system_time_as_filetime_t)(LPFILETIME); -static get_system_time_as_filetime_t - my_GetSystemTimePreciseAsFileTime= GetSystemTimeAsFileTime; #endif + #ifdef HAVE_LINUX_UNISTD_H #include <linux/unistd.h> #endif @@ -57,20 +55,12 @@ ulonglong my_interval_timer() #elif defined(HAVE_GETHRTIME) return gethrtime(); #elif defined(_WIN32) + DBUG_ASSERT(query_performance_frequency); LARGE_INTEGER t_cnt; - if (query_performance_frequency) - { - QueryPerformanceCounter(&t_cnt); - return (t_cnt.QuadPart / query_performance_frequency * 1000000000ULL) + + QueryPerformanceCounter(&t_cnt); + return (t_cnt.QuadPart / query_performance_frequency * 1000000000ULL) + ((t_cnt.QuadPart % query_performance_frequency) * 1000000000ULL / query_performance_frequency); - } - else - { - ulonglong newtime; - my_GetSystemTimePreciseAsFileTime((FILETIME*)&newtime); - return newtime*100ULL; - } #else /* TODO: check for other possibilities for hi-res timestamping */ struct timeval tv; @@ -87,7 +77,7 @@ my_hrtime_t my_hrtime() my_hrtime_t hrtime; #if defined(_WIN32) ulonglong newtime; - my_GetSystemTimePreciseAsFileTime((FILETIME*)&newtime); + GetSystemTimePreciseAsFileTime((FILETIME*)&newtime); hrtime.val= (newtime - OFFSET_TO_EPOC)/10; #elif defined(HAVE_CLOCK_GETTIME) struct timespec tp; @@ -127,14 +117,8 @@ void my_time_init() #ifdef _WIN32 compile_time_assert(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); - if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0) - query_performance_frequency= 0; - - get_system_time_as_filetime_t f= (get_system_time_as_filetime_t) - GetProcAddress(GetModuleHandle("kernel32"), - "GetSystemTimePreciseAsFileTime"); - if (f) - my_GetSystemTimePreciseAsFileTime= f; + QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency); + DBUG_ASSERT(query_performance_frequency); #endif } |