From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6923 invoked by alias); 1 Sep 2015 15:08:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 6903 invoked by uid 89); 1 Sep 2015 15:08:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 01 Sep 2015 15:08:49 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 75038C0EF9A1; Tue, 1 Sep 2015 15:08:48 +0000 (UTC) Received: from localhost (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t81F8lPx012464; Tue, 1 Sep 2015 11:08:47 -0400 Date: Tue, 01 Sep 2015 15:08:00 -0000 From: Jonathan Wakely To: Dmitry Vyukov Cc: GCC Patches , libstdc++@gcc.gnu.org, Alexander Potapenko , Kostya Serebryany , Torvald Riegel Subject: Re: [Patch, libstdc++] Fix data races in basic_string implementation Message-ID: <20150901150847.GH2631@redhat.com> References: <20150901142713.GG2631@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-09/txt/msg00073.txt.bz2 On 01/09/15 16:56 +0200, Dmitry Vyukov wrote: >I don't understand how a new gcc may not support __atomic builtins on >ints. How it is even possible? That's a portable API provided by >recent gcc's... The built-in function is always defined, but it might expand to a call to an external function in libatomic, and it would be a regression for code using std::string to start requiring libatomic (although maybe it would be necessary if it's the only way to make the code correct). I don't know if there are any targets that define __GTHREADS and also don't support __atomic_load(int*, ...) without libatomic. If such targets exist then adding a new configure check that only depends on __atomic_load(int*, ...) would mean we keep supporting those targets. Another option would be to simply do: bool _M_is_shared() const _GLIBCXX_NOEXCEPT #if defined(__GTHREADS) + { return __atomic_load(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0; } +#else { return this->_M_refcount > 0; } +#endif and see if anyone complains!