diff mbox

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

Message ID 1415305499-37330-1-git-send-email-waterman@cs.berkeley.edu
State New
Headers show

Commit Message

Andrew Waterman Nov. 6, 2014, 8:24 p.m. UTC
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(-)

Comments

Richard Henderson Nov. 7, 2014, 1:20 p.m. UTC | #1
On 11/06/2014 09:24 PM, Andrew Waterman wrote:
> 2014-10-23  Andrew Waterman <waterman@cs.berkeley.edu>
> 
>   * cas_n.c (libat_compare_exchange): Add missing cast.

Ok.


r~
Andrew Waterman Nov. 9, 2014, 12:35 a.m. UTC | #2
Thank you for approving the patch.  I neglected to mention that I do
not have write access.  Would you or someone else be so kind as to
commit this?

On Fri, Nov 7, 2014 at 5:20 AM, Richard Henderson <rth@redhat.com> wrote:
> On 11/06/2014 09:24 PM, Andrew Waterman wrote:
>> 2014-10-23  Andrew Waterman <waterman@cs.berkeley.edu>
>>
>>   * cas_n.c (libat_compare_exchange): Add missing cast.
>
> Ok.
>
>
> r~
Jeff Law Nov. 14, 2014, 6:06 a.m. UTC | #3
On 11/08/14 17:35, Andrew Waterman wrote:
> Thank you for approving the patch.  I neglected to mention that I do
> not have write access.  Would you or someone else be so kind as to
> commit this?
Done.  Thanks for your patience.

Jeff
diff mbox

Patch

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