Commit 7c24467a authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

added g_atomic_pointer_set() and g_atomic_int_set() for systems where the

Tue Dec 13 10:13:32 2005  Tim Janik  <timj@imendio.com>

        * glib/gatomic.h: added g_atomic_pointer_set() and g_atomic_int_set()
        for systems where the initialization of atomic variables requires a
        write memory barrier.
parent 2e6faeec
Tue Dec 13 10:13:32 2005 Tim Janik <timj@imendio.com>
* glib/gatomic.h: added g_atomic_pointer_set() and g_atomic_int_set()
for systems where the initialization of atomic variables requires a
write memory barrier.
2005-12-09 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version
......
Tue Dec 13 10:13:32 2005 Tim Janik <timj@imendio.com>
* glib/gatomic.h: added g_atomic_pointer_set() and g_atomic_int_set()
for systems where the initialization of atomic variables requires a
write memory barrier.
2005-12-09 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version
......
Tue Dec 13 10:13:32 2005 Tim Janik <timj@imendio.com>
* glib/gatomic.h: added g_atomic_pointer_set() and g_atomic_int_set()
for systems where the initialization of atomic variables requires a
write memory barrier.
2005-12-09 Matthias Clasen <mclasen@redhat.com>
* configure.in: Bump version
......
......@@ -613,6 +613,15 @@ g_atomic_int_get (volatile gint *atomic)
return result;
}
void
g_atomic_int_set (volatile gint *atomic,
gint newval)
{
g_mutex_lock (g_atomic_mutex);
*atomic = newval;
g_mutex_unlock (g_atomic_mutex);
}
gpointer
g_atomic_pointer_get (volatile gpointer *atomic)
{
......@@ -624,6 +633,15 @@ g_atomic_pointer_get (volatile gpointer *atomic)
return result;
}
void
g_atomic_pointer_set (volatile gpointer *atomic,
gpointer newval)
{
g_mutex_lock (g_atomic_mutex);
*atomic = newval;
g_mutex_unlock (g_atomic_mutex);
}
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
#elif defined (G_ATOMIC_OP_MEMORY_BARRIER_NEEDED)
gint
......
......@@ -34,23 +34,29 @@
G_BEGIN_DECLS
gint g_atomic_int_exchange_and_add (volatile gint *atomic,
gint val);
void g_atomic_int_add (volatile gint *atomic,
gint val);
gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic,
gint oldval,
gint g_atomic_int_exchange_and_add (volatile gint *atomic,
gint val);
void g_atomic_int_add (volatile gint *atomic,
gint val);
gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic,
gint oldval,
gint newval);
gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
gpointer oldval,
gpointer newval);
gint g_atomic_int_get (volatile gint *atomic);
void g_atomic_int_set (volatile gint *atomic,
gint newval);
gpointer g_atomic_pointer_get (volatile gpointer *atomic);
void g_atomic_pointer_set (volatile gpointer *atomic,
gpointer newval);
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
# define g_atomic_int_get(atomic) (*(atomic))
# define g_atomic_pointer_get(atomic) (*(atomic))
# define g_atomic_int_get(atomic) (*(atomic))
# define g_atomic_int_set(atomic, newval) ((void) (*(atomic) = (newval)))
# define g_atomic_pointer_get(atomic) (*(atomic))
# define g_atomic_pointer_set(atomic, newval) ((void) (*(atomic) = (newval)))
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
#define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment