00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __G_ATOMIC_H__
00032 #define __G_ATOMIC_H__
00033
00034 #include <_ansi.h>
00035 #include <glib/gtypes.h>
00036
00037 G_BEGIN_DECLS
00038
00039 IMPORT_C gint g_atomic_int_exchange_and_add (volatile gint *atomic,
00040 gint val);
00041 IMPORT_C void g_atomic_int_add (volatile gint *atomic,
00042 gint val);
00043 IMPORT_C gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic,
00044 gint oldval,
00045 gint newval);
00046 IMPORT_C gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
00047 gpointer oldval,
00048 gpointer newval);
00049
00050 IMPORT_C gint g_atomic_int_get (volatile gint *atomic);
00051 IMPORT_C void g_atomic_int_set (volatile gint *atomic,
00052 gint newval);
00053 IMPORT_C gpointer g_atomic_pointer_get (volatile gpointer *atomic);
00054 IMPORT_C void g_atomic_pointer_set (volatile gpointer *atomic,
00055 gpointer newval);
00056
00057 #ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
00058 # define g_atomic_int_get(atomic) (*(atomic))
00059 # define g_atomic_int_set(atomic, newval) ((void) (*(atomic) = (newval)))
00060 # define g_atomic_pointer_get(atomic) (*(atomic))
00061 # define g_atomic_pointer_set(atomic, newval) ((void) (*(atomic) = (newval)))
00062 #endif
00063
00064 #define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1))
00065 #define g_atomic_int_dec_and_test(atomic) \
00066 (g_atomic_int_exchange_and_add ((atomic), -1) == 1)
00067
00068 G_END_DECLS
00069
00070 #endif