diff mbox

[libstdc++] Improve slightly __cxa_guard_acquire

Message ID 20120911150258.GR22619@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 11, 2012, 3:02 p.m. UTC
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.


	Jakub

Comments

Richard Henderson Sept. 11, 2012, 3:14 p.m. UTC | #1
On 09/11/2012 08:02 AM, Jakub Jelinek wrote:
> 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.

Looks good.


r~
diff mbox

Patch

--- 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;