List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:December 15 2010 8:00pm
Subject:bzr commit into mysql-5.5-bugteam branch (davi:3196)
View as plain text  
# At a local mysql-5.5-bugteam repository of davi

 3196 Davi Arnaut	2010-12-15
      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.

    modified:
      mysys/my_init.c
=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2010-08-16 12:50:27 +0000
+++ b/mysys/my_init.c	2010-12-15 20:00:54 +0000
@@ -311,6 +311,89 @@ int handle_rtc_failure(int err_type, con
 #pragma runtime_checks("", restore)
 #endif
 
+#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
+#define MS 10000000
+
+static void win_init_time(void)
+{
+  /* The following is used by time functions */
+  FILETIME ft;
+  LARGE_INTEGER li, t_cnt;
+
+  DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
+
+  if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
+    query_performance_frequency= 0;
+  else
+  {
+    GetSystemTimeAsFileTime(&ft);
+    li.LowPart=  ft.dwLowDateTime;
+    li.HighPart= ft.dwHighDateTime;
+    query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
+    QueryPerformanceCounter(&t_cnt);
+    query_performance_offset-= (t_cnt.QuadPart /
+                                query_performance_frequency * MS +
+                                t_cnt.QuadPart %
+                                query_performance_frequency * MS /
+                                query_performance_frequency);
+  }
+}
+
+
+/*
+  Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
+  there as environment variables
+*/
+static void win_init_registry(void)
+{
+  HKEY key_handle;
+
+  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
+                    0, KEY_READ, &key_handle) == ERROR_SUCCESS)
+  {
+    LONG ret;
+    DWORD index= 0;
+    DWORD type;
+    char key_name[256], key_data[1024];
+    DWORD key_name_len= sizeof(key_name) - 1;
+    DWORD key_data_len= sizeof(key_data) - 1;
+
+    while ((ret= RegEnumValue(key_handle, index++,
+                              key_name, &key_name_len,
+                              NULL, &type, (LPBYTE)&key_data,
+                              &key_data_len)) != ERROR_NO_MORE_ITEMS)
+    {
+      char env_string[sizeof(key_name) + sizeof(key_data) + 2];
+
+      if (ret == ERROR_MORE_DATA)
+      {
+        /* Registry value larger than 'key_data', skip it */
+        DBUG_PRINT("error", ("Skipped registry value that was too large"));
+      }
+      else if (ret == ERROR_SUCCESS)
+      {
+        if (type == REG_SZ)
+        {
+          strxmov(env_string, key_name, "=", key_data, NullS);
+
+          /* variable for putenv must be allocated ! */
+          putenv(strdup(env_string)) ;
+        }
+      }
+      else
+      {
+        /* Unhandled error, break out of loop */
+        break;
+      }
+
+      key_name_len= sizeof(key_name) - 1;
+      key_data_len= sizeof(key_data) - 1;
+    }
+
+    RegCloseKey(key_handle);
+  }
+}
+
 
 static void my_win_init(void)
 {
@@ -318,17 +401,18 @@ static void my_win_init(void)
 
 #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 
+  _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  
+#endif
+
 #ifdef __MSVC_RUNTIME_CHECKS
   /*
     Install handler to send RTC (Runtime Error Check) warnings
@@ -339,106 +423,10 @@ static void my_win_init(void)
 
   _tzset();
 
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-               
-  /* The following is used by time functions */
-#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10)
-#define MS 10000000
-  {
-    FILETIME ft;
-    LARGE_INTEGER li, t_cnt;
-    DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency));
-    if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0)
-      query_performance_frequency= 0;
-    else
-    {
-      GetSystemTimeAsFileTime(&ft);
-      li.LowPart=  ft.dwLowDateTime;
-      li.HighPart= ft.dwHighDateTime;
-      query_performance_offset= li.QuadPart-OFFSET_TO_EPOC;
-      QueryPerformanceCounter(&t_cnt);
-      query_performance_offset-= (t_cnt.QuadPart /
-                                  query_performance_frequency * MS +
-                                  t_cnt.QuadPart %
-                                  query_performance_frequency * MS /
-                                  query_performance_frequency);
-    }
-  }
+  win_init_time();
+  win_init_registry();
 
-  {
-    /*
-      Open HKEY_LOCAL_MACHINE\SOFTWARE\MySQL and set any strings found
-      there as environment variables
-    */
-    HKEY key_handle;
-    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)"SOFTWARE\\MySQL",
-                     0, KEY_READ, &key_handle) == ERROR_SUCCESS)
-    {
-      LONG ret;
-      DWORD index= 0;
-      DWORD type;
-      char key_name[256], key_data[1024];
-      DWORD key_name_len= sizeof(key_name) - 1;
-      DWORD key_data_len= sizeof(key_data) - 1;
-
-      while ((ret= RegEnumValue(key_handle, index++,
-                                key_name, &key_name_len,
-                                NULL, &type, (LPBYTE)&key_data,
-                                &key_data_len)) != ERROR_NO_MORE_ITEMS)
-      {
-        char env_string[sizeof(key_name) + sizeof(key_data) + 2];
-
-        if (ret == ERROR_MORE_DATA)
-        {
-          /* Registry value larger than 'key_data', skip it */
-          DBUG_PRINT("error", ("Skipped registry value that was too large"));
-        }
-        else if (ret == ERROR_SUCCESS)
-        {
-          if (type == REG_SZ)
-          {
-            strxmov(env_string, key_name, "=", key_data, NullS);
-
-            /* variable for putenv must be allocated ! */
-            putenv(strdup(env_string)) ;
-          }
-        }
-        else
-        {
-          /* Unhandled error, break out of loop */
-          break;
-        }
-
-        key_name_len= sizeof(key_name) - 1;
-        key_data_len= sizeof(key_data) - 1;
-      }
-
-      RegCloseKey(key_handle) ;
-    }
-  }
-  DBUG_VOID_RETURN ;
+  DBUG_VOID_RETURN;
 }
 
 


Attachment: [text/bzr-bundle] bzr/davi.arnaut@oracle.com-20101215200054-vij52dprwmtu821b.bundle
Thread
bzr commit into mysql-5.5-bugteam branch (davi:3196) Davi Arnaut15 Dec