added win32 api based implementation for G_PLATFORM_WIN32, !__GNUC__
authorHans Breuer <hans@breuer.org>
Sun, 29 Feb 2004 21:32:27 +0000 (21:32 +0000)
committerHans Breuer <hans@src.gnome.org>
Sun, 29 Feb 2004 21:32:27 +0000 (21:32 +0000)
2003-02-29  Hans Breuer  <hans@breuer.org>

* glib/gatomic.c : added win32 api based implementation
for G_PLATFORM_WIN32, !__GNUC__

* glb/glib.def : change to g_atomi_* no _fallback

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gatomic.c
glib/glib.def

index 4fcb4fe..eea2a1d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index 4fcb4fe..eea2a1d 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index 4fcb4fe..eea2a1d 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index 4fcb4fe..eea2a1d 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index 4fcb4fe..eea2a1d 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index 4fcb4fe..eea2a1d 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-29  Hans Breuer  <hans@breuer.org>
+
+       * 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  <seppi@seppi.de>
 
        * configure.in, glib/gatomic.c, glib/gatomic.h: Moved the
index a0ee1a8..cf3de33 100644 (file)
@@ -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 <windows.h>
+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);
index 112b612..a41b24a 100644 (file)
@@ -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