mirror of
https://github.com/postgres/postgres.git
synced 2025-10-21 02:52:47 +03:00
Further atomic ops portability improvements and bug fixes.
* Don't play tricks for a more efficient pg_atomic_clear_flag() in the generic gcc implementation. The old version was broken on gcc < 4.7 on !x86 platforms. Per buildfarm member chipmunk. * Make usage of __atomic() fences depend on HAVE_GCC__ATOMIC_INT32_CAS instead of HAVE_GCC__ATOMIC_INT64_CAS - there's platforms with 32bit support that don't support 64bit atomics. * Blindly fix two superflous #endif in generic-xlc.h * Check for --disable-atomics in platforms but x86.
This commit is contained in:
@@ -40,19 +40,19 @@
|
||||
* definitions where possible, and use this only as a fallback.
|
||||
*/
|
||||
#if !defined(pg_memory_barrier_impl)
|
||||
# if defined(HAVE_GCC__ATOMIC_INT64_CAS)
|
||||
# if defined(HAVE_GCC__ATOMIC_INT32_CAS)
|
||||
# define pg_memory_barrier_impl() __atomic_thread_fence(__ATOMIC_SEQ_CST)
|
||||
# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
|
||||
# define pg_memory_barrier_impl() __sync_synchronize()
|
||||
# endif
|
||||
#endif /* !defined(pg_memory_barrier_impl) */
|
||||
|
||||
#if !defined(pg_read_barrier_impl) && defined(HAVE_GCC__ATOMIC_INT64_CAS)
|
||||
#if !defined(pg_read_barrier_impl) && defined(HAVE_GCC__ATOMIC_INT32_CAS)
|
||||
/* acquire semantics include read barrier semantics */
|
||||
# define pg_read_barrier_impl() __atomic_thread_fence(__ATOMIC_ACQUIRE)
|
||||
#endif
|
||||
|
||||
#if !defined(pg_write_barrier_impl) && defined(HAVE_GCC__ATOMIC_INT64_CAS)
|
||||
#if !defined(pg_write_barrier_impl) && defined(HAVE_GCC__ATOMIC_INT32_CAS)
|
||||
/* release semantics include write barrier semantics */
|
||||
# define pg_write_barrier_impl() __atomic_thread_fence(__ATOMIC_RELEASE)
|
||||
#endif
|
||||
@@ -139,13 +139,7 @@ pg_atomic_unlocked_test_flag_impl(volatile pg_atomic_flag *ptr)
|
||||
static inline void
|
||||
pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
|
||||
{
|
||||
/*
|
||||
* XXX: It would be nicer to use __sync_lock_release here, but gcc insists
|
||||
* on making that an atomic op which is far to expensive and a stronger
|
||||
* guarantee than what we actually need.
|
||||
*/
|
||||
pg_write_barrier_impl();
|
||||
ptr->value = 0;
|
||||
__sync_lock_release(&ptr->value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user