From patchwork Tue Feb 14 03:22:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v3] libstdc++/51798 Date: Mon, 13 Feb 2012 17:22:09 -0000 From: Benjamin Kosnik X-Patchwork-Id: 141042 Message-Id: <20120213192209.5086d48f@shotwell> To: Richard Henderson Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, jakub@redhat.com > The patch uses the weak version of compare_exchange universally, which > is incorrect in a number of cases. You wouldn't see this on x86_64; > you'd have to use a ll/sc target such as powerpc. > > In addition to changing several uses to strong compare_exchange, I > also optimize the idiom > > do > { > var = *m; > newval = ...; > } > while (!atomic_compare_exchange(m, &var, newval, ...)); > > With the new builtins, VAR is updated with the current value of the > memory (regardless of the weak setting), so the initial read from *M > can be hoisted outside the loop. nice! > > Ok? cool, thanks for reviewing this. I fixed up the line numbers for the header file edits. -benjamin 2012-02-13 Benjamin Kosnik * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line numbers. * testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same. diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc index 0d51663..39f9ce3 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc @@ -32,9 +32,9 @@ void test01() { X* px = 0; std::shared_ptr p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 773 } + // { dg-error "incomplete" "" { target *-*-* } 771 } std::shared_ptr p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 867 } + // { dg-error "incomplete" "" { target *-*-* } 865 } } diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc index ae902dc..0309f8f 100644 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc @@ -1,6 +1,6 @@ // { dg-do compile } -// Copyright (C) 2010 Free Software Foundation +// Copyright (C) 2010, 2012 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -30,9 +30,9 @@ void test01() { X* px = 0; std::tr1::shared_ptr p1(px); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 565 } + // { dg-error "incomplete" "" { target *-*-* } 563 } std::tr1::shared_ptr p9(ap()); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 604 } + // { dg-error "incomplete" "" { target *-*-* } 602 } }