win32: remove version init from g_thread_init_glib
authorRyan Lortie <desrt@desrt.ca>
Fri, 9 Sep 2011 17:15:17 +0000 (13:15 -0400)
committerRyan Lortie <desrt@desrt.ca>
Fri, 9 Sep 2011 17:17:42 +0000 (13:17 -0400)
Instead, make this use g_once_init_enter() in the usual way.

glib/gthread.c
glib/gthreadprivate.h
glib/gwin32.c

index 62902b4..bc99389 100644 (file)
@@ -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,
index fdd803a..e7f0ce4 100644 (file)
@@ -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__ */
index d69f4dd..800c89c 100644 (file)
@@ -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;
 }