+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
+2004-03-05 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
+
+ * glib/gatomic.c: Fix infinite recursion for
+ G_MEMORY_BARRIER_NEEDED and DEFINE_WITH_MUTEXES by using a GMutex
+ instead of G_DEFINE_LOCK. The mutex is allocated by the new
+ function _g_atomic_thread_init. Fixes #136284.
+
+ * glib/gthreadinit.h, glib/gthread.c: Declare and call
+ _g_atomic_thread_init during thread system initialization.
+
2004-03-05 Tor Lillqvist <tml@iki.fi>
* glib/glib.def: Add g_main_depth. (#136221, Cedric Gustin)
#ifdef DEFINE_WITH_MUTEXES
/* We have to use the slow, but safe locking method */
-G_LOCK_DEFINE_STATIC (g_atomic_lock);
+static GMutex *g_atomic_mutex;
+
gint
g_atomic_int_exchange_and_add (gint *atomic,
gint val)
{
gint result;
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
result = *atomic;
*atomic += val;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
return result;
}
g_atomic_int_add (gint *atomic,
gint val)
{
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
*atomic += val;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
}
gboolean
{
gboolean result;
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
if (*atomic == oldval)
{
result = TRUE;
}
else
result = FALSE;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
return result;
}
{
gboolean result;
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
if (*atomic == oldval)
{
result = TRUE;
}
else
result = FALSE;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
return result;
}
{
gint result;
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
result = *atomic;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
return result;
}
{
gpointer result;
- G_LOCK (g_atomic_lock);
+ g_mutex_lock (g_atomic_mutex);
result = *atomic;
- G_UNLOCK (g_atomic_lock);
+ g_mutex_unlock (g_atomic_mutex);
return result;
}
while (!ATOMIC_INT_CMP_XCHG (atomic, result, result + val));
}
#endif /* ATOMIC_INT_CMP_XCHG */
+
+void
+_g_atomic_thread_init ()
+{
+#ifdef DEFINE_WITH_MUTEXES
+ g_atomic_mutex = g_mutex_new ();
+#endif /* DEFINE_WITH_MUTEXES */
+}
_g_main_thread_init ();
_g_mem_thread_init ();
_g_messages_thread_init ();
-
+ _g_atomic_thread_init ();
+
g_threads_got_initialized = TRUE;
g_thread_specific_private = g_private_new (g_thread_cleanup);
void _g_convert_thread_init (void);
void _g_rand_thread_init (void);
void _g_main_thread_init (void);
+void _g_atomic_thread_init (void);
/* Are called from glib/gthread.c. Must only contain g_private_new calls */
void _g_mem_thread_private_init (void);