This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH, libstdc++] Improve slightly __cxa_guard_acquire
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Benjamin De Kosnik <bkoz at redhat dot com>, Richard Henderson <rth at redhat dot com>
- Cc: Thiago Macieira <thiago dot macieira at intel dot com>, gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Tue, 11 Sep 2012 17:02:58 +0200
- Subject: Re: [PATCH, libstdc++] Improve slightly __cxa_guard_acquire
- References: <2255222.Ergk1VO0fz@tjmaciei-mobl2> <20120906114552.636de147@coso> <20120906133311.3de386a8@coso> <20120906211037.GC22619@tucnak.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Sep 06, 2012 at 11:10:37PM +0200, Jakub Jelinek wrote:
> > + int expected(0);
> > if (__atomic_compare_exchange_n(gi, &expected, pending_bit, false,
> > __ATOMIC_ACQ_REL,
> > __ATOMIC_RELAXED))
>
> Shouldn't this __ATOMIC_RELAXED be also __ATOMIC_ACQUIRE? If expected ends
> up being guard_bit, then the code will return 0; right away.
Here is a patch for that. Ok for trunk/4.7?
2012-09-11 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/54172
* libsupc++/guard.cc (__cxa_guard_acquire): Fix up the last
argument of the first __atomic_compare_exchange_n.
--- libstdc++-v3/libsupc++/guard.cc.jj 2012-09-11 16:55:16.000000000 +0200
+++ libstdc++-v3/libsupc++/guard.cc 2012-09-11 16:56:38.035848876 +0200
@@ -253,7 +253,7 @@ namespace __cxxabiv1
int expected(0);
if (__atomic_compare_exchange_n(gi, &expected, pending_bit, false,
__ATOMIC_ACQ_REL,
- __ATOMIC_RELAXED))
+ __ATOMIC_ACQUIRE))
{
// This thread should do the initialization.
return 1;
Jakub