Skip to content
Permalink
Browse files
Fix innodb compilation failure on Windows
We don't need to print an error when loading kernel32.dll. If we can't
load it we'll automatically crash. Reviewed by wlad@mariadb.com
  • Loading branch information
cvicentiu committed Jan 25, 2018
1 parent 12c42bd commit f775ee6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
@@ -3645,9 +3645,7 @@ innobase_init(

#ifndef UNIV_HOTBACKUP
#ifdef _WIN32
if (ut_win_init_time()) {
goto mem_free_and_error;
}
ut_win_init_time();
#endif /* _WIN32 */
#endif /* !UNIV_HOTBACKUP */

@@ -275,9 +275,10 @@ ut_time_ms(void);
/*============*/
#ifdef _WIN32
/**********************************************************//**
Initialise highest available time resolution API on Windows
@return 0 if all OK else -1 */
int
Initialise highest available time resolution API on Windows.
Crashes if there's an error loading kernel32.dll.
*/
void
ut_win_init_time();

#endif /* _WIN32 */
@@ -49,7 +49,6 @@ Created 5/11/1994 Heikki Tuuri
UNIV_INTERN ibool ut_always_false = FALSE;

#ifdef __WIN__
#include <mysql/innodb_priv.h> /* For sql_print_error */
typedef VOID(WINAPI *time_fn)(LPFILETIME);
static time_fn ut_get_system_time_as_file_time = GetSystemTimeAsFileTime;

@@ -61,25 +60,20 @@ epoch starts from 1970/1/1. For selection of constant see:


/**
Initialise highest available time resolution API on Windows
@return 0 if all OK else -1 */
int
Initialise highest available time resolution API on Windows.
Crashes if there's an error loading kernel32.dll.
*/
void
ut_win_init_time()
{
HMODULE h = LoadLibrary("kernel32.dll");
if (h != NULL)
ut_a(h);
time_fn pfn = (time_fn)GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
if (pfn != NULL)
{
time_fn pfn = (time_fn)GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
if (pfn != NULL)
{
ut_get_system_time_as_file_time = pfn;
}
return false;
ut_get_system_time_as_file_time = pfn;
}
DWORD error = GetLastError();
sql_print_error(
"LoadLibrary(\"kernel32.dll\") failed: GetLastError returns %lu", error);
return(-1);
return;
}

/*****************************************************************//**

0 comments on commit f775ee6

Please sign in to comment.