dbus/cmake
Simon McVittie 88b5749984 sysdeps: Use C11 stdatomic.h where possible
On Unix, dbus has historically used gcc-specific lock-free atomic
intrinsics where available, falling back to a pthreads mutex where
possible. Meanwhile, on Windows, it has historically used
InterlockedIncrement() and similar library functions (in practice
wrappers around lock-free intrinsics on real Windows, but IPC calls into
wineserver on Wine).

ISO C11 provides a new header, stdatomic.h, with standardized support
for atomic operations. Exactly how these are implemented is a compiler
quality-of-implementation decision, but any reasonable compiler
implementation on a modern CPU should be using intrinsics. Let's use
this wherever possible, falling back to our old implementation only if
the C11 implementation is unsupported.

One concrete benefit that we get from this is that when compiling with
mingw-w64 gcc and running via Wine, this makes atomic reference counting
operations into a simple local operation, rather than IPC to wineserver
which can be very slow. This should make our CI tests considerably more
reliable.

In all vaguely modern gcc versions (gcc 5.5 or later) and in contemporary
versions of clang, the default compiler mode is C11 or later with GNU
extensions. We intentionally do not ask for any specific C standard, so
we can use C11 features like this one, as long as we do so conditionally.

The Microsoft Visual C compiler does not currently support this without
special options, so we still use the Interlocked family of functions
when compiling for Windows with MSVC.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-08-15 12:54:41 +00:00
..
bus Move cmake related build system to top level 2019-01-22 09:57:40 +01:00
modules Let cmake retrieve version and variable information from meson build system 2023-08-07 16:10:21 +02:00
bus-test.bat.cmake * cmake: new directory, contains cmake build support. 2007-03-03 14:32:17 +00:00
config.h.cmake sysdeps: Use C11 stdatomic.h where possible 2023-08-15 12:54:41 +00:00
ConfigureChecks.cmake sysdeps: Use C11 stdatomic.h where possible 2023-08-15 12:54:41 +00:00
dbus-env.bat.cmake Split DBUS_SESSION_BUS_DEFAULT_ADDRESS into listen, connect addresses and set better defaults 2012-08-13 19:57:13 +01:00
DBus1Config.cmake.in cmake: In generated cmake support files get value for DBus1_INCLUDE_DIRS variable from related cmake target 2021-11-18 13:51:11 +00:00
DBus1Config.pkgconfig.in cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake 2022-03-30 07:36:38 +00:00
DBus1ConfigVersion.cmake.in cmake, autotools: Add find package config support for cmake clients 2017-03-20 14:18:45 +00:00
i686-w64-mingw32.cmake cmake: Fix warning on travis-ci 'CMAKE_FORCE_C.._COMPILER macro is deprecated' 2018-03-21 15:02:38 +01:00
meson.build build: Add machine-readable licensing markers to the Meson build system 2022-07-13 20:36:13 +01:00
x86_64-w64-mingw32.cmake travis-ci: Add cross building support for mingw 64 bit compiler 2018-03-22 21:13:47 +01:00