#endif
}
+/**
+ * Atomically get the value of an integer. It may change at any time
+ * thereafter, so this is mostly only useful for assertions.
+ *
+ * @param atomic pointer to the integer to get
+ * @returns the value at this moment
+ */
+dbus_int32_t
+_dbus_atomic_get (DBusAtomic *atomic)
+{
+#if DBUS_USE_SYNC
+ __sync_synchronize ();
+ return atomic->value;
+#else
+ dbus_int32_t res;
+
+ _DBUS_LOCK (atomic);
+ res = atomic->value;
+ _DBUS_UNLOCK (atomic);
+ return res;
+#endif
+}
+
#ifdef DBUS_BUILD_TESTS
/** Gets our GID
* @returns process GID
}
/**
+ * Atomically get the value of an integer. It may change at any time
+ * thereafter, so this is mostly only useful for assertions.
+ *
+ * @param atomic pointer to the integer to get
+ * @returns the value at this moment
+ */
+dbus_int32_t
+_dbus_atomic_get (DBusAtomic *atomic)
+{
+ /* this is what GLib does, hopefully it's right... */
+ MemoryBarrier ();
+ return atomic->value;
+}
+
+/**
* Called when the bus daemon is signaled to reload its configuration; any
* caches should be nuked. Of course any caches that need explicit reload
* are probably broken, but c'est la vie.
return _dbus_strerror (errno);
}
-/**
- * Atomically get the value of an integer. It may change at any time
- * thereafter, so this is mostly only useful for assertions.
- *
- * This function temporarily increases the atomic integer, so only
- * use it in contexts where that would be OK (such as refcounts).
- *
- * @param atomic pointer to the integer to increment
- * @returns the value at this moment
- */
-dbus_int32_t
-_dbus_atomic_get (DBusAtomic *atomic)
-{
- dbus_int32_t old_value;
-
- /* On Windows we use InterlockedIncrement and InterlockedDecrement,
- * and there is no InterlockedGet, so we have to change the value.
- * Increasing it is less likely to have bad side-effects (for instance,
- * it's OK for refcounts). */
- old_value = _dbus_atomic_inc (atomic);
- _dbus_atomic_dec (atomic);
- return old_value;
-}
-
/** @} end of sysdeps */
/* tests in dbus-sysdeps-util.c */