Based on advice from Dmitry Vyukov, this patch fixes the use of __atomic_compare_exchange_n in libgo. The Go library assumes a strong compare-exchange operation, and always assumes sequential consistency around the operation. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu, where, as it happens, this patch makes no different anyhow. Committed to mainline.
Ian
diff -r db71d396d9e5 libgo/runtime/runtime.h --- a/libgo/runtime/runtime.h Fri Nov 16 08:03:04 2012 -0800 +++ b/libgo/runtime/runtime.h Fri Nov 16 16:43:50 2012 -0800 @@ -518,7 +518,7 @@ void free(void *v); #define runtime_cas(pval, old, new) __sync_bool_compare_and_swap (pval, old, new) #define runtime_casp(pval, old, new) __sync_bool_compare_and_swap (pval, old, new) -#define runtime_cas64(pval, pold, new) __atomic_compare_exchange_n (pval, pold, new, 1, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED) +#define runtime_cas64(pval, pold, new) __atomic_compare_exchange_n (pval, pold, new, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) #define runtime_xadd(p, v) __sync_add_and_fetch (p, v) #define runtime_xadd64(p, v) __sync_add_and_fetch (p, v) #define runtime_xchg(p, v) __atomic_exchange_n (p, v, __ATOMIC_SEQ_CST)