From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24835 invoked by alias); 18 Feb 2015 12:15:23 -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 24797 invoked by uid 89); 18 Feb 2015 12:15:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham 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; Wed, 18 Feb 2015 12:15:16 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1ICFDLi004025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 18 Feb 2015 07:15:14 -0500 Received: from localhost (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1ICFCnt006296; Wed, 18 Feb 2015 07:15:13 -0500 Date: Wed, 18 Feb 2015 12:15:00 -0000 From: Jonathan Wakely To: Richard Henderson Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [libstdc++/65033] Give alignment info to libatomic Message-ID: <20150218121512.GI3360@redhat.com> References: <54DD19B7.6060401@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <54DD19B7.6060401@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-02/txt/msg01095.txt.bz2 On 12/02/15 13:23 -0800, Richard Henderson wrote: >When we fixed PR54005, making sure that atomic_is_lock_free returns the same >value for all objects of a given type, we probably should have changed the >interface so that we would pass size and alignment rather than size and object >pointer. > >Instead, we decided that passing null for the object pointer would be >sufficient. But as this PR shows, we really do need to take alignment into >account. > >The following patch constructs a fake object pointer that is maximally >misaligned. This allows the interface to both the builtin and to libatomic to >remain unchanged. Which probably makes this back-portable to maintenance >releases as well. Am I right in thinking that another option would be to ensure that std::atomic<> objects are always suitably aligned? Would that make std::atomic<> slightly more compatible with a C11 atomic_int, where the _Atomic qualifier affects alignment? https://gcc.gnu.org/PR62259 suggests we might need to enforce alignment on std::atomic anyway, or am I barking up the wrong tree?