mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-17 23:47:52 +02:00
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
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
# This file makes most of the thread related macros look like
|
||||
# functions, which they really were, if possible easy.
|
||||
|
||||
<MACRO>
|
||||
<NAME>G_ATOMIC_LOCK_FREE</NAME>
|
||||
#define G_ATOMIC_LOCK_FREE
|
||||
</MACRO>
|
||||
|
||||
# default thread implementation
|
||||
|
||||
<MACRO>
|
||||
|
@@ -806,6 +806,9 @@ g_async_queue_sort_unlocked
|
||||
<SECTION>
|
||||
<TITLE>Atomic Operations</TITLE>
|
||||
<FILE>atomic_operations</FILE>
|
||||
G_ATOMIC_LOCK_FREE
|
||||
|
||||
<SUBSECTION>
|
||||
g_atomic_int_get
|
||||
g_atomic_int_set
|
||||
g_atomic_int_inc
|
||||
|
Reference in New Issue
Block a user