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)
committerAnas Nashif <anas.nashif@intel.com>
Wed, 19 Jun 2013 10:07:33 +0000 (06:07 -0400)
commitbb50ec03725b9f94dcca18d1c1256c253e9d0198
tree5942258fcbc7655d4b15964678a5372600312405
parentd90972efe786775f93c12e158c5902e0d7c76240
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>
Applied-upstream: 1.7.4, commit:c36f21a2e91730e9ae52e8945305aa3072f0e508
Bug-Tizen: TZPC-1971
Change-Id: I91d99a86f25d49d63d79eebfe85767bb8cc66170
dbus/dbus-internals.h
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-win.c
dbus/dbus-threads.c