gatomic: introduce G_ATOMIC_LOCK_FREE
authorRyan Lortie <desrt@desrt.ca>
Tue, 18 Oct 2011 20:21:50 +0000 (16:21 -0400)
committerRyan Lortie <desrt@desrt.ca>
Tue, 18 Oct 2011 20:45:28 +0000 (16:45 -0400)
commitaba0f0c38bbfa11ad48b5410ebdbed2a99e68c58
tree7ea87ff14a2c6a2a7fba8ab7127c070e7529c0f7
parentc9b6c3c85ac8f870ff193ae75b2bd19a7a310ec9
gatomic: introduce G_ATOMIC_LOCK_FREE

We clean up the detection of if we should do 'real' atomic operations or
mutex-emulated ones with the introduction of a new (public) macro:
G_ATOMIC_LOCK_FREE.  If defined, our atomic operations are guaranteed to
be done in hardware.

We need to use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to determine if our
compiler supports GCC-style atomic operations from the gatomic.h header
because we might be building a program against GLib using a different
set of compiler options (or a different compiler) than was used to build
GLib itself.

Unfortunately, this macro is not available on clang, so it has currently
regressed to using the mutex emulation.  A bug about that has been
opened here:

  http://llvm.org/bugs/show_bug.cgi?id=11174
configure.ac
docs/reference/glib/glib-overrides.txt
docs/reference/glib/glib-sections.txt
glib/gatomic.c
glib/gatomic.h
glib/glibconfig.h.win32.in