diff options
-rw-r--r-- | src/include/gcc.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/include/gcc.h b/src/include/gcc.h index 2efbb20b39a..7135bd479c7 100644 --- a/src/include/gcc.h +++ b/src/include/gcc.h @@ -87,18 +87,25 @@ * To avoid locking shared data structures such as statistics and to permit * atomic state changes, we rely on the WT_ATOMIC_ADD and WT_ATOMIC_CAS * (compare and swap) operations. - * - * Note that we avoid __sync_bool_compare_and_swap due to problems with - * optimization with some versions of clang. See - * http://llvm.org/bugs/show_bug.cgi?id=21499 for details. */ #define __WT_ATOMIC_ADD(v, val, n) \ (WT_STATIC_ASSERT(sizeof(v) == (n)), __sync_add_and_fetch(&(v), val)) #define __WT_ATOMIC_FETCH_ADD(v, val, n) \ (WT_STATIC_ASSERT(sizeof(v) == (n)), __sync_fetch_and_add(&(v), val)) +#ifdef __clang__ +/* + * We avoid __sync_bool_compare_and_swap with due to problems with + * optimization with some versions of clang. See + * http://llvm.org/bugs/show_bug.cgi?id=21499 for details. + */ #define __WT_ATOMIC_CAS(v, old, new, n) \ (WT_STATIC_ASSERT(sizeof(v) == (n)), \ __sync_val_compare_and_swap(&(v), old, new) == (old)) +#else +#define __WT_ATOMIC_CAS(v, old, new, n) \ + (WT_STATIC_ASSERT(sizeof(v) == (n)), \ + __sync_bool_compare_and_swap(&(v), old, new)) +#endif #define __WT_ATOMIC_CAS_VAL(v, old, new, n) \ (WT_STATIC_ASSERT(sizeof(v) == (n)), \ __sync_val_compare_and_swap(&(v), old, new)) |