DBusAtomic: on Unix, use pthreads mutexes for fallback
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 15 Apr 2013 12:51:19 +0000 (13:51 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 9 May 2013 09:32:54 +0000 (10:32 +0100)
commitc36f21a2e91730e9ae52e8945305aa3072f0e508
treee2aead3eb7ae2df9042aac40411bfddb9a1231f6
parent7ac9b68220a2f48bc2942aaa909d6ba1f4605f73
DBusAtomic: on Unix, use pthreads mutexes for fallback

On pthreads platforms, POSIX guarantees that we can "allocate" mutexes
as library-global variables, without involving malloc. This means we
don't need to error-check their allocation - if the dynamic linker
succeeds, then we have enough memory for all our globals - which is an
important step towards being thread-safe by default. In particular,
making atomic operations never rely on DBusMutex means that we are free
to implement parts of DBusMutex in terms of DBusAtomic, if it would help.

We do not currently support any non-Windows platform that does not have
pthreads. This is unlikely to change.

On Windows, we already used real atomic operations; we can just
delete the unused global variable.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
dbus/dbus-internals.h
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-win.c
dbus/dbus-threads.c