From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128925 invoked by alias); 31 Mar 2015 15:03:43 -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 128899 invoked by uid 89); 31 Mar 2015 15:03:42 -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; Tue, 31 Mar 2015 15:03:32 +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 (Postfix) with ESMTPS id D1EA7B040F; Tue, 31 Mar 2015 15:03:30 +0000 (UTC) Received: from localhost (ovpn-116-96.ams2.redhat.com [10.36.116.96]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2VF3TYA011655; Tue, 31 Mar 2015 11:03:30 -0400 Date: Tue, 31 Mar 2015 15:03:00 -0000 From: Jonathan Wakely To: Richard Henderson Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org, Andrew MacLeod Subject: Re: [libstdc++/65033] Give alignment info to libatomic Message-ID: <20150331150329.GT9755@redhat.com> References: <54DD19B7.6060401@redhat.com> <20150218121512.GI3360@redhat.com> <20150325162244.GF9755@redhat.com> <5513003D.3040107@redhat.com> <20150325184913.GH9755@redhat.com> <551306C1.6060702@redhat.com> <20150326132147.GL9755@redhat.com> <20150331134136.GS9755@redhat.com> <551AB523.5040203@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <551AB523.5040203@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-03/txt/msg01671.txt.bz2 On 31/03/15 07:54 -0700, Richard Henderson wrote: >On 03/31/2015 06:41 AM, Jonathan Wakely wrote: >> This is the best I've come up with, does anyone have any better ideas >> than the #else branch to hardcode alignment of 16-byte types to 16? > >If there's no 16 byte type, are we convinced this matters? I mean, there isn't >a 16-byte atomic instruction for 32-bit x86 (or any other 32-bit cpu of which I >am aware). So we're forced to use a locking path anyway. The C front end gives struct S { char s[16]; } 16 byte alignment, and I'd like std::atomic and _Atomic struct S to be layout compatible, although it's not essential (or required by any standard). And it matters most for the integral types, not arbitrary structs. >And if we do want the alignment, do we stop pretending with all the sizeof's >and alignof's and just use power-of-two size alignment for all of them, e.g. > > min_align = ((size & (size - 1)) || size > 16 ? 0 : size) Yeah, I wondered about that too. Joseph indicated there are targets where C gives alignof(_Atomic X) != sizeof(X), which is why the target hook exists, but maybe we can just not worry about those targets for now. For GCC 6 we can look into the new attribute Andrew did in the atomics branch so that we can make std::atomic use the target hook directly instead of trying to simulate its effects in C++ code.