[PATCH] Fix sub-word CAS synthesis on LP64 targets
Andrew Waterman
waterman@eecs.berkeley.edu
Fri Oct 24 04:36:00 GMT 2014
A missing cast causes the compare value to be truncated, resulting in
spurious CAS failures.
The problem manifested in a new port I'm working on as a failure in test
gcc.dg/atomic/c11-atomic-exec-2.c, and I've confirmed that this patch
fixes it. I also verified that x86_64-unknown-linux still bootstraps
(which is admittedly vacuous, since x86-64 doesn't exercise this code).
2014-10-23 Andrew Waterman <waterman@cs.berkeley.edu>
* cas_n.c (libat_compare_exchange): Add missing cast.
---
libatomic/cas_n.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libatomic/cas_n.c b/libatomic/cas_n.c
index 801262d..a885afa 100644
--- a/libatomic/cas_n.c
+++ b/libatomic/cas_n.c
@@ -70,7 +70,7 @@ SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
mask = -1;
}
- weval = *eptr << shift;
+ weval = (UWORD)*eptr << shift;
wnewval = (UWORD)newval << shift;
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
do
--
2.1.1
More information about the Gcc-patches
mailing list