From patchwork Tue Sep 11 15:02:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 183135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E73B82C0092 for ; Wed, 12 Sep 2012 01:04:43 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347980685; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=iyRZn7O3OLYnqsKrRbrE9yZbp+I=; b=FuGbaRz+hJNREq5 nSlp0pipdbE3x2UMSjRIrel2aUeKEOEBsH1IbYE5tO22cmAVWLLugdLpeUvz38dD OBwArWTrzCHukIMIS6iYvrKE+VgeH9nW8Ow2VhN5tu8um601smweyGdVmX1oBtxY E8wTpzrnRu7scmJpWXqxTeg5rUf8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=u0239iGLhG2+zVqbKEkiyaBoqe/gd/p6UMVIZsuoF6biWKYF/MI343CROsNZI5 y1pASLt/tfhOsxmP5Dh9YCYvohHPPc8Bi29IXNm+YKcYY0WQrBjqYk8Z7tHSE5Fy ZR8a18Dm85EYwMtPyjsikzW7V+h/6SJXOZ2/EGH/SKvJA=; Received: (qmail 16735 invoked by alias); 11 Sep 2012 15:04:34 -0000 Received: (qmail 16682 invoked by uid 22791); 11 Sep 2012 15:04:33 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CX X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Sep 2012 15:04:16 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8BF4GFs004310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Sep 2012 11:04:16 -0400 Received: from tucnak.redhat.com (vpn1-4-246.ams2.redhat.com [10.36.4.246]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8BF4EUF012088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 11 Sep 2012 11:04:15 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id q8BF2xUN031754; Tue, 11 Sep 2012 17:02:59 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id q8BF2wYS031753; Tue, 11 Sep 2012 17:02:58 +0200 Date: Tue, 11 Sep 2012 17:02:58 +0200 From: Jakub Jelinek To: Benjamin De Kosnik , Richard Henderson Cc: Thiago Macieira , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH, libstdc++] Improve slightly __cxa_guard_acquire Message-ID: <20120911150258.GR22619@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <2255222.Ergk1VO0fz@tjmaciei-mobl2> <20120906114552.636de147@coso> <20120906133311.3de386a8@coso> <20120906211037.GC22619@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120906211037.GC22619@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 PR libstdc++/54172 * libsupc++/guard.cc (__cxa_guard_acquire): Fix up the last argument of the first __atomic_compare_exchange_n. Jakub --- 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;