[glib] win32: remove version init from g_thread_init_glib



commit 80109acef586a5a1d34f604414a36e7e18b0cede
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Sep 9 13:15:17 2011 -0400

    win32: remove version init from g_thread_init_glib
    
    Instead, make this use g_once_init_enter() in the usual way.

 glib/gthread.c        |    3 ---
 glib/gthreadprivate.h |    4 ----
 glib/gwin32.c         |   33 ++++++++-------------------------
 3 files changed, 8 insertions(+), 32 deletions(-)
---
diff --git a/glib/gthread.c b/glib/gthread.c
index 62902b4..bc99389 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -964,9 +964,6 @@ g_thread_init_glib (void)
   _g_main_thread_init ();
   _g_utils_thread_init ();
   _g_futex_thread_init ();
-#ifdef G_OS_WIN32
-  _g_win32_thread_init ();
-#endif
 }
 
 /* The following sections implement: GOnce, GStaticMutex, GStaticRecMutex,
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index fdd803a..e7f0ce4 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -61,10 +61,6 @@ G_GNUC_INTERNAL void _g_utils_thread_init (void);
 G_GNUC_INTERNAL void _g_futex_thread_init (void);
 G_GNUC_INTERNAL void _g_thread_impl_init  (void);
 
-#ifdef G_OS_WIN32
-G_GNUC_INTERNAL void _g_win32_thread_init (void);
-#endif /* G_OS_WIN32 */
-
 G_END_DECLS
 
 #endif /* __G_THREADPRIVATE_H__ */
diff --git a/glib/gwin32.c b/glib/gwin32.c
index d69f4dd..800c89c 100644
--- a/glib/gwin32.c
+++ b/glib/gwin32.c
@@ -52,6 +52,7 @@
 #endif /* _MSC_VER || __DMC__ */
 
 #include "glib.h"
+#include "gthreadprivate.h"
 
 #ifdef G_WITH_CYGWIN
 #include <sys/cygwin.h>
@@ -492,29 +493,6 @@ g_win32_get_package_installation_subdirectory (const gchar *package,
 
 #endif
 
-static guint windows_version;
-
-static void 
-g_win32_windows_version_init (void)
-{
-  static gboolean beenhere = FALSE;
-
-  if (!beenhere)
-    {
-      beenhere = TRUE;
-      windows_version = GetVersion ();
-
-      if (windows_version & 0x80000000)
-	g_error ("This version of GLib requires NT-based Windows.");
-    }
-}
-
-void 
-_g_win32_thread_init (void)
-{
-  g_win32_windows_version_init ();
-}
-
 /**
  * g_win32_get_windows_version:
  *
@@ -535,8 +513,13 @@ _g_win32_thread_init (void)
 guint
 g_win32_get_windows_version (void)
 {
-  g_win32_windows_version_init ();
-  
+  static gsize windows_version;
+
+  g_thread_init_glib ();
+
+  if (g_once_init_enter (&windows_version))
+    g_once_init_leave (&windows_version, GetVersion ());
+
   return windows_version;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]