Commit 73fe55d7 by Ian Lance Taylor

re PR go/89199 (libgo regression in implementation of CompareAndSwap functions…

re PR go/89199 (libgo regression in implementation of CompareAndSwap functions resulting in intermittent testcase failures on ppc64le power9 after r268458)

	PR go/89199
    sync/atomic: use strong form of atomic_compare_exchange_n
    
    In the recent change to use atomic_compare_exchange_n I thought we
    could use the weak form, which can spuriously fail. But that is not
    how it is implemented in the gc library, and it is not what the rest
    of the library expects.
    
    Thanks to Lynn Boger for identifying the problem.
    
    Fixes https://gcc.gnu.org/PR89199
    
    Reviewed-on: https://go-review.googlesource.com/c/161359

From-SVN: r268591
parent 16e2bcd5
74ffeddbe6fef446129af65581b3a9094715bc22 d89db31db68d09aa13a6137122cc096c1d92597b
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -69,7 +69,7 @@ _Bool CompareAndSwapInt32 (int32_t *, int32_t, int32_t) ...@@ -69,7 +69,7 @@ _Bool CompareAndSwapInt32 (int32_t *, int32_t, int32_t)
_Bool _Bool
CompareAndSwapInt32 (int32_t *val, int32_t old, int32_t new) CompareAndSwapInt32 (int32_t *val, int32_t old, int32_t new)
{ {
return __atomic_compare_exchange_n (val, &old, new, true, __ATOMIC_SEQ_CST, return __atomic_compare_exchange_n (val, &old, new, false, __ATOMIC_SEQ_CST,
__ATOMIC_RELAXED); __ATOMIC_RELAXED);
} }
...@@ -82,7 +82,7 @@ CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new) ...@@ -82,7 +82,7 @@ CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new)
{ {
if (((uintptr_t) val & 7) != 0) if (((uintptr_t) val & 7) != 0)
val = NULL; val = NULL;
return __atomic_compare_exchange_n (val, &old, new, true, __ATOMIC_SEQ_CST, return __atomic_compare_exchange_n (val, &old, new, false, __ATOMIC_SEQ_CST,
__ATOMIC_RELAXED); __ATOMIC_RELAXED);
} }
...@@ -93,7 +93,7 @@ _Bool CompareAndSwapUint32 (uint32_t *, uint32_t, uint32_t) ...@@ -93,7 +93,7 @@ _Bool CompareAndSwapUint32 (uint32_t *, uint32_t, uint32_t)
_Bool _Bool
CompareAndSwapUint32 (uint32_t *val, uint32_t old, uint32_t new) CompareAndSwapUint32 (uint32_t *val, uint32_t old, uint32_t new)
{ {
return __atomic_compare_exchange_n (val, &old, new, true, __ATOMIC_SEQ_CST, return __atomic_compare_exchange_n (val, &old, new, false, __ATOMIC_SEQ_CST,
__ATOMIC_RELAXED); __ATOMIC_RELAXED);
} }
...@@ -106,7 +106,7 @@ CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new) ...@@ -106,7 +106,7 @@ CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new)
{ {
if (((uintptr_t) val & 7) != 0) if (((uintptr_t) val & 7) != 0)
val = NULL; val = NULL;
return __atomic_compare_exchange_n (val, &old, new, true, __ATOMIC_SEQ_CST, return __atomic_compare_exchange_n (val, &old, new, false, __ATOMIC_SEQ_CST,
__ATOMIC_RELAXED); __ATOMIC_RELAXED);
} }
...@@ -117,7 +117,7 @@ _Bool CompareAndSwapUintptr (uintptr_t *, uintptr_t, uintptr_t) ...@@ -117,7 +117,7 @@ _Bool CompareAndSwapUintptr (uintptr_t *, uintptr_t, uintptr_t)
_Bool _Bool
CompareAndSwapUintptr (uintptr_t *val, uintptr_t old, uintptr_t new) CompareAndSwapUintptr (uintptr_t *val, uintptr_t old, uintptr_t new)
{ {
return __atomic_compare_exchange_n (val, &old, new, true, __ATOMIC_SEQ_CST, return __atomic_compare_exchange_n (val, &old, new, false, __ATOMIC_SEQ_CST,
__ATOMIC_RELAXED); __ATOMIC_RELAXED);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment