1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Cleanup my_win_init by moving time and registry related

initialization to specific functions. Also, remove a large
block of white space. There shouldn't be any functional
change.
This commit is contained in:
Davi Arnaut
2010-12-15 18:00:54 -02:00
parent ac665ecf06
commit 7941c7eaaf

View File

@@ -311,65 +311,17 @@ int handle_rtc_failure(int err_type, const char *file, int line,
#pragma runtime_checks("", restore) #pragma runtime_checks("", restore)
#endif #endif
static void my_win_init(void)
{
DBUG_ENTER("my_win_init");
#if defined(_MSC_VER)
#if _MSC_VER < 1300
/*
Clear the OS system variable TZ and avoid the 100% CPU usage
Only for old versions of Visual C++
*/
_putenv( "TZ=" );
#endif
#if _MSC_VER >= 1400
/* this is required to make crt functions return -1 appropriately */
_set_invalid_parameter_handler(my_parameter_handler);
#endif
#endif
#ifdef __MSVC_RUNTIME_CHECKS
/*
Install handler to send RTC (Runtime Error Check) warnings
to log file
*/
_RTC_SetErrorFunc(handle_rtc_failure);
#endif
_tzset();
/* The following is used by time functions */
#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) #define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
#define MS 10000000 #define MS 10000000
static void win_init_time(void)
{ {
/* The following is used by time functions */
FILETIME ft; FILETIME ft;
LARGE_INTEGER li, t_cnt; LARGE_INTEGER li, t_cnt;
DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0) if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
query_performance_frequency= 0; query_performance_frequency= 0;
else else
@@ -387,12 +339,15 @@ static void my_win_init(void)
} }
} }
{
/* /*
Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
there as environment variables there as environment variables
*/ */
static void win_init_registry(void)
{
HKEY key_handle; HKEY key_handle;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL", if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
0, KEY_READ, &key_handle) == ERROR_SUCCESS) 0, KEY_READ, &key_handle) == ERROR_SUCCESS)
{ {
@@ -438,6 +393,39 @@ static void my_win_init(void)
RegCloseKey(key_handle); RegCloseKey(key_handle);
} }
} }
static void my_win_init(void)
{
DBUG_ENTER("my_win_init");
#if defined(_MSC_VER)
#if _MSC_VER < 1300
/*
Clear the OS system variable TZ and avoid the 100% CPU usage
Only for old versions of Visual C++
*/
_putenv("TZ=");
#endif
#if _MSC_VER >= 1400
/* this is required to make crt functions return -1 appropriately */
_set_invalid_parameter_handler(my_parameter_handler);
#endif
#endif
#ifdef __MSVC_RUNTIME_CHECKS
/*
Install handler to send RTC (Runtime Error Check) warnings
to log file
*/
_RTC_SetErrorFunc(handle_rtc_failure);
#endif
_tzset();
win_init_time();
win_init_registry();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }