This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ping] libatomic: Fix sub-word CAS synthesis on LP64 targets


Greetings.  This is just a ping about a one-liner.  The original email was
here and is inlined below.

https://gcc.gnu.org/ml/gcc-patches/2014-10/msg02465.html

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]