mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-08 19:38:01 +02:00
Use InterlockedExchange to get a full memory barrier on Windows
See the bug for extensive discussion. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41423 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
parent
96cb1542c2
commit
1e494ecc60
1 changed files with 12 additions and 2 deletions
|
|
@ -3121,8 +3121,18 @@ _dbus_atomic_dec (DBusAtomic *atomic)
|
|||
dbus_int32_t
|
||||
_dbus_atomic_get (DBusAtomic *atomic)
|
||||
{
|
||||
/* this is what GLib does, hopefully it's right... */
|
||||
MemoryBarrier ();
|
||||
/* In this situation, GLib issues a MemoryBarrier() and then returns
|
||||
* atomic->value. However, mingw from mingw.org (not to be confused with
|
||||
* mingw-w64 from mingw-w64.sf.net) does not have MemoryBarrier in its
|
||||
* headers, so we have to get a memory barrier some other way.
|
||||
*
|
||||
* InterlockedIncrement is older, and is documented on MSDN to be a full
|
||||
* memory barrier, so let's use that.
|
||||
*/
|
||||
long dummy = 0;
|
||||
|
||||
InterlockedExchange (&dummy, 1);
|
||||
|
||||
return atomic->value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue