--- glib-2.12.4-org//glib/gthread.c	2006-05-22 21:33:16.000000000 -0400
+++ glib-2.12.4/glib/gthread.c	2006-11-02 16:38:30.000000000 -0500
@@ -44,6 +44,8 @@
 #include "gthreadprivate.h"
 #include "galias.h"
 
+#include <glib/ghash.h> /* for g_once_init_enter */
+
 GQuark
 g_thread_error_quark (void)
 {
@@ -109,6 +111,9 @@
 static GPrivate *g_thread_specific_private = NULL;
 static GRealThread *g_thread_all_threads = NULL;
 static GSList   *g_thread_free_indeces = NULL;
+static GMutex   *g_once_init_mutex = NULL;
+static GCond    *g_once_init_cond = NULL;
+static GHashTable *g_once_init_hashtable = NULL;
 
 G_LOCK_DEFINE_STATIC (g_thread);
 
@@ -127,7 +132,10 @@
   /* mutex and cond creation works without g_threads_got_initialized */
   g_once_mutex = g_mutex_new ();
   g_once_cond = g_cond_new ();
-
+  g_once_init_mutex = g_mutex_new();
+  g_once_init_cond = g_cond_new();
+  g_once_init_hashtable = g_hash_table_new(NULL, NULL);
+  
   /* we may only create mutex and cond in here */
   _g_mem_thread_init_noprivate_nomessage ();
 
@@ -181,6 +189,45 @@
 
   return once->retval;
 }
+gboolean  g_once_init_enter (volatile gsize *value_location)
+{
+  
+  if (g_atomic_pointer_get (value_location) !=0)
+  {
+    return FALSE;
+  }
+  g_mutex_lock(g_once_init_mutex);
+  
+  if (!g_hash_table_lookup(g_once_init_hashtable, (gpointer) value_location))
+  {
+    g_hash_table_insert(g_once_init_hashtable, (gpointer)  value_location, (gpointer) 1);
+    g_mutex_unlock(g_once_init_mutex);
+    return  TRUE;
+  }
+  else
+  {
+    while(g_hash_table_lookup(g_once_init_hashtable, (gpointer) value_location))
+      g_cond_wait(g_once_init_cond, g_once_init_mutex);
+    
+      g_mutex_unlock(g_once_init_mutex);
+  }
+  
+  return FALSE;  
+}
+
+
+void  g_once_init_leave (volatile gsize *value_location,  gsize value)
+{
+  g_return_if_fail (*value_location == 0);
+
+  *value_location = value;
+  
+  g_mutex_lock(g_once_init_mutex);
+  g_hash_table_remove(g_once_init_hashtable, value_location);
+  g_cond_broadcast (g_once_init_cond);
+  g_mutex_unlock(g_once_init_mutex);
+  
+}
 
 void
 g_static_mutex_init (GStaticMutex *mutex)
--- glib-2.12.4-org//glib/gthread.h	2006-05-10 20:18:46.000000000 -0400
+++ glib-2.12.4/glib/gthread.h	2006-11-02 16:38:30.000000000 -0500
@@ -112,6 +112,8 @@
 GLIB_VAR gboolean               g_thread_use_default_impl;
 GLIB_VAR gboolean               g_threads_got_initialized;
 
+
+
 /* initializes the mutex/cond/private implementation for glib, might
  * only be called once, and must not be called directly or indirectly
  * from another glib-function, e.g. as a callback.
@@ -320,6 +322,9 @@
    g_once_impl ((once), (func), (arg)))
 #endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
     
+gboolean  g_once_init_enter (volatile gsize *value_location);
+void  g_once_init_leave (volatile gsize *value_location,  gsize value);
+
 /* these are some convenience macros that expand to nothing if GLib
  * was configured with --disable-threads. for using StaticMutexes,
  * you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)
