diff --git a/ChangeLog b/ChangeLog index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4fcb4fe5d..eea2a1d44 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2003-02-29 Hans Breuer + + * glib/gatomic.c : added win32 api based implementation + for G_PLATFORM_WIN32, !__GNUC__ + + * glb/glib.def : change to g_atomi_* no _fallback + 2004-02-29 Sebastian Wilhelmi * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the diff --git a/glib/gatomic.c b/glib/gatomic.c index a0ee1a8ef..cf3de33eb 100644 --- a/glib/gatomic.c +++ b/glib/gatomic.c @@ -417,9 +417,52 @@ g_atomic_pointer_compare_and_exchange (gpointer *atomic, # define DEFINE_WITH_MUTEXES # endif /* G_ATOMIC */ #else /* !__GNUC__ */ -# define DEFINE_WITH_MUTEXES +# ifdef G_PLATFORM_WIN32 +# define DEFINE_WITH_WIN32_INTERLOCKED +# else +# define DEFINE_WITH_MUTEXES +# endif #endif /* __GNUC__ */ +#ifdef DEFINE_WITH_WIN32_INTERLOCKED +# include +gint32 +g_atomic_int_exchange_and_add (gint32 *atomic, + gint32 val) +{ + return InterlockedExchangeAdd (atomic, val); +} + +void +g_atomic_int_add (gint32 *atomic, + gint32 val) +{ + InterlockedExchangeAdd (atomic, val); +} + +gboolean +g_atomic_int_compare_and_exchange (gint32 *atomic, + gint32 oldval, + gint32 newval) +{ + return (guint32)InterlockedCompareExchange ((PVOID*)atomic, + (PVOID)newval, + (PVOID)oldval) == oldval; +} + +gboolean +g_atomic_pointer_compare_and_exchange (gpointer *atomic, + gpointer oldval, + gpointer newval) +{ +# if GLIB_SIZEOF_VOID_P != 4 /* no 32-bit system */ +# error "InterlockedCompareExchangePointer needed" +# else + return InterlockedCompareExchange (atomic, newval, oldval) == oldval; +# endif +} +#endif /* DEFINE_WITH_WIN32_INTERLOCKED */ + #ifdef DEFINE_WITH_MUTEXES /* We have to use the slow, but safe locking method */ G_LOCK_DEFINE_STATIC (g_atomic_lock); diff --git a/glib/glib.def b/glib/glib.def index 112b612df..a41b24a58 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -44,12 +44,12 @@ EXPORTS g_async_queue_unref g_async_queue_unref_and_unlock g_atexit - g_atomic_int_add_fallback - g_atomic_int_compare_and_exchange_fallback - g_atomic_int_exchange_and_add_fallback -; g_atomic_int_get_fallback - g_atomic_pointer_compare_and_exchange_fallback -; g_atomic_pointer_get_fallback + g_atomic_int_add + g_atomic_int_compare_and_exchange + g_atomic_int_exchange_and_add +; g_atomic_int_get + g_atomic_pointer_compare_and_exchange +; g_atomic_pointer_get g_basename g_bit_nth_lsf g_bit_nth_msf