]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* dbus/dbus-sysdeps-unix.c: moved _dbus_atomic_inc/dec()
authorRalf Habacker <ralf.habacker@freenet.de>
Sun, 31 Dec 2006 12:16:04 +0000 (12:16 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Sun, 31 Dec 2006 12:16:04 +0000 (12:16 +0000)
from dbus/dbus-sysdeps.c, windows version of _dbus_atomic_inc/dec()
is in dbus-sysdeps-win.c (not in this patch).

* dbus/dbus-sysdeps.h: DBusAtomic::value is long on windows to fit
with InterlockedInc/Decrement. - Patches from Christian Ehrlicher

ChangeLog
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps.c
dbus/dbus-sysdeps.h

index 7a87110493a617141ecf8fbc43b80902b7e2795f..fd93c9d6e0d182cd5d379531b3ddee9bf3f29769 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-12-31  Ralf Habacker  <ralf.habacker@freenet.de>
+
+       * dbus/dbus-sysdeps-unix.c: moved _dbus_atomic_inc/dec() 
+       from dbus/dbus-sysdeps.c, windows version of _dbus_atomic_inc/dec() 
+       is in dbus-sysdeps-win.c (not in this patch).
+
+       * dbus/dbus-sysdeps.h: DBusAtomic::value is long on windows to fit 
+       with InterlockedInc/Decrement. 
+       - Patches from Christian Ehrlicher
+       
 2006-12-31  Ralf Habacker  <ralf.habacker@freenet.de>
 
        * tools/dbus-send.c, tools/dbus-monitor.c: win32 compile fix.
index f4afad8965915a64c72a6ae0a25ca331ed9d86f0..9b6457b2d4be5925b97eddba71653a7c4fa16701 100644 (file)
@@ -1428,6 +1428,53 @@ _dbus_getuid (void)
   return getuid ();
 }
 
+/**
+ * Atomically increments an integer
+ *
+ * @param atomic pointer to the integer to increment
+ * @returns the value before incrementing
+ *
+ * @todo implement arch-specific faster atomic ops
+ */
+dbus_int32_t
+_dbus_atomic_inc (DBusAtomic *atomic)
+{
+#ifdef DBUS_USE_ATOMIC_INT_486
+  return atomic_exchange_and_add (atomic, 1);
+#else
+  dbus_int32_t res;
+  _DBUS_LOCK (atomic);
+  res = atomic->value;
+  atomic->value += 1;
+  _DBUS_UNLOCK (atomic);
+  return res;
+#endif
+}
+
+/**
+ * Atomically decrement an integer
+ *
+ * @param atomic pointer to the integer to decrement
+ * @returns the value before decrementing
+ *
+ * @todo implement arch-specific faster atomic ops
+ */
+dbus_int32_t
+_dbus_atomic_dec (DBusAtomic *atomic)
+{
+#ifdef DBUS_USE_ATOMIC_INT_486
+  return atomic_exchange_and_add (atomic, -1);
+#else
+  dbus_int32_t res;
+  
+  _DBUS_LOCK (atomic);
+  res = atomic->value;
+  atomic->value -= 1;
+  _DBUS_UNLOCK (atomic);
+  return res;
+#endif
+}
+
 #ifdef DBUS_BUILD_TESTS
 /** Gets our GID
  * @returns process GID
index 0ad29fe38ca103f8e31f5812ef75474cadcd4218..5bd202af58a76910cef4f2e2ab7a8fad7c1521d8 100644 (file)
@@ -662,53 +662,6 @@ atomic_exchange_and_add (DBusAtomic            *atomic,
 }
 #endif
 
-/**
- * Atomically increments an integer
- *
- * @param atomic pointer to the integer to increment
- * @returns the value before incrementing
- *
- * @todo implement arch-specific faster atomic ops
- */
-dbus_int32_t
-_dbus_atomic_inc (DBusAtomic *atomic)
-{
-#ifdef DBUS_USE_ATOMIC_INT_486
-  return atomic_exchange_and_add (atomic, 1);
-#else
-  dbus_int32_t res;
-  _DBUS_LOCK (atomic);
-  res = atomic->value;
-  atomic->value += 1;
-  _DBUS_UNLOCK (atomic);
-  return res;
-#endif
-}
-
-/**
- * Atomically decrement an integer
- *
- * @param atomic pointer to the integer to decrement
- * @returns the value before decrementing
- *
- * @todo implement arch-specific faster atomic ops
- */
-dbus_int32_t
-_dbus_atomic_dec (DBusAtomic *atomic)
-{
-#ifdef DBUS_USE_ATOMIC_INT_486
-  return atomic_exchange_and_add (atomic, -1);
-#else
-  dbus_int32_t res;
-  
-  _DBUS_LOCK (atomic);
-  res = atomic->value;
-  atomic->value -= 1;
-  _DBUS_UNLOCK (atomic);
-  return res;
-#endif
-}
-
 void
 _dbus_generate_pseudorandom_bytes_buffer (char *buffer,
                                           int   n_bytes)
index 2218cfc1262612e8fb371d661bb4db6d65ff9997..9bc911868e4ba29298cc12424a623f6553580448 100644 (file)
@@ -229,7 +229,11 @@ typedef struct DBusAtomic DBusAtomic;
  */
 struct DBusAtomic
 {
+#ifdef DBUS_WIN
+  volatile long value; /**< Value of the atomic integer. */
+#else
   volatile dbus_int32_t value; /**< Value of the atomic integer. */
+#endif
 };
 
 dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic);