utils: Use GCC's __atomic built-ins if available

These are available since GCC 4.7 and will eventually replace the __sync
operations.  They support the memory model defined by C++11. For instance,
by using __ATOMIC_RELAXED for some operations on the reference counters we
can avoid memory barriers, which are required by __sync operations (whose
memory model essentially is __ATOMIC_SEQ_CST).
This commit is contained in:
Tobias Brunner
2014-04-24 17:54:14 +02:00
parent efedd0d21e
commit 0f603d425d
3 changed files with 47 additions and 10 deletions
+2 -2
View File
@@ -511,7 +511,7 @@ void nop()
{
}
#ifndef HAVE_GCC_ATOMIC_OPERATIONS
#if !defined(HAVE_GCC_ATOMIC_OPERATIONS) && !defined(HAVE_GCC_SYNC_OPERATIONS)
/**
* We use a single mutex for all refcount variables.
@@ -578,7 +578,7 @@ bool cas_##name(type *ptr, type oldval, type newval) \
_cas_impl(bool, bool)
_cas_impl(ptr, void*)
#endif /* HAVE_GCC_ATOMIC_OPERATIONS */
#endif /* !HAVE_GCC_ATOMIC_OPERATIONS && !HAVE_GCC_SYNC_OPERATIONS */
#ifdef HAVE_FMEMOPEN_FALLBACK