From ac010f614aaa9d80d3674ad497d1c289d2a4cb7c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 26 Oct 2011 18:32:52 +0400 Subject: [PATCH] Add note about __sync_bool_compare_and_swap usage (gcc/x86.h) * src/atomic_ops/sysdeps/gcc/x86.h (AO_compare_and_swap_full): Add comment for __sync_bool_compare_and_swap regarding variables protection list. * src/atomic_ops/sysdeps/gcc/x86_64.h (AO_compare_and_swap_full): Likewise. --- src/atomic_ops/sysdeps/gcc/x86.h | 6 +++++- src/atomic_ops/sysdeps/gcc/x86_64.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/atomic_ops/sysdeps/gcc/x86.h b/src/atomic_ops/sysdeps/gcc/x86.h index 6709eca..b304dd0 100644 --- a/src/atomic_ops/sysdeps/gcc/x86.h +++ b/src/atomic_ops/sysdeps/gcc/x86.h @@ -134,7 +134,11 @@ AO_INLINE int AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) { # ifdef AO_USE_SYNC_CAS_BUILTIN - return (int)__sync_bool_compare_and_swap(addr, old, new_val); + return (int)__sync_bool_compare_and_swap(addr, old, new_val + /* empty protection list */); + /* Note: an empty list of variables protected by the */ + /* memory barrier should mean all globally accessible */ + /* variables are protected. */ # else char result; __asm__ __volatile__("lock; cmpxchgl %3, %0; setz %1" diff --git a/src/atomic_ops/sysdeps/gcc/x86_64.h b/src/atomic_ops/sysdeps/gcc/x86_64.h index 823069b..9225270 100644 --- a/src/atomic_ops/sysdeps/gcc/x86_64.h +++ b/src/atomic_ops/sysdeps/gcc/x86_64.h @@ -131,7 +131,8 @@ AO_INLINE int AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) { # ifdef AO_USE_SYNC_CAS_BUILTIN - return (int)__sync_bool_compare_and_swap(addr, old, new_val); + return (int)__sync_bool_compare_and_swap(addr, old, new_val + /* empty protection list */); # else char result; __asm__ __volatile__("lock; cmpxchgq %3, %0; setz %1" -- 2.50.0