summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2006-12-31 12:16:04 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2006-12-31 12:16:04 +0000
commit2dae3a600ba5adfa47645438843e9d61b171d019 (patch)
tree456b8a88507d2604447ae84fe195b9820215d0c3 /dbus
parent572ae0a7d4c8bc7849422f948eb9cc6239bed4c1 (diff)
* 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
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-sysdeps-unix.c47
-rw-r--r--dbus/dbus-sysdeps.c47
-rw-r--r--dbus/dbus-sysdeps.h4
3 files changed, 51 insertions, 47 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index f4afad89..9b6457b2 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -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
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 0ad29fe3..5bd202af 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -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)
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 2218cfc1..9bc91186 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -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);