} 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); } GType g_test_get_type (void) { static GType test_type = 0; if(g_once_init_enter(&test_type)) { static const GTypeInfo test_info = { sizeof (GTestClass), NULL, NULL, (GClassInitFunc) g_test_class_init, NULL, NULL, sizeof (GTest), 0, (GInstanceInitFunc) g_test_init, NULL }; GType id = g_type_register_static (G_TYPE_OBJECT, "GTest", &test_info, 0); g_once_init_leave(&test_type, id); } return test_type; }