From patchwork Thu Apr 2 08:15:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 5987 Received: (qmail 50119 invoked by alias); 2 Apr 2015 08:15:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50101 invoked by uid 89); 2 Apr 2015 08:15:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Message-ID: <551CFAB8.2000005@redhat.com> Date: Thu, 02 Apr 2015 10:15:52 +0200 From: Florian Weimer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Andreas Schwab CC: GNU C Library Subject: Re: [PATCH] Define libc_max_align_t References: <551C1A60.4080507@redhat.com> <87h9szqzi9.fsf@igel.home> <551C6E87.2090607@redhat.com> In-Reply-To: On 04/02/2015 09:38 AM, Andreas Schwab wrote: > Florian Weimer writes: > >> On 04/02/2015 12:01 AM, Andreas Schwab wrote: >>> Florian Weimer writes: >>> >>>> +/* This mirrors the C11 max_align_t type provided by GCC, but it is >>>> + also available in C99 mode. */ >>>> +typedef struct { >>>> + long long ll __attribute__ ((__aligned__ (__alignof__ (long long)))); >>>> + long double ld __attribute__ ((__aligned__ (__alignof__ (long double)))); >>>> +} libc_max_align_t; >>> >>> Why aren't the attributes no-ops? >> >> Quoting Joseph: >> >> “The attributes there are because some targets may give types lower >> alignment inside structures and unions than outside; 32-bit x86 in >> particular.” > > This should probably be added to the comment. Well, the GCC folks thought it wasn't necessary, but I agree that a comment cannot hurt. Is this okay? From 1d39ccadab8f2c11ac54242c9faaf0396f760c15 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 2 Apr 2015 10:07:04 +0200 Subject: [PATCH] Define libc_max_align_t for internal use --- ChangeLog | 4 ++++ include/libc-internal.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index c687d13..b0a48ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-04-02 Florian Weimer + + * include/libc-internal.h (libc_max_align_t): Define. + 2015-04-02 Mel Gorman [BZ #17195] diff --git a/include/libc-internal.h b/include/libc-internal.h index bca59a4..b37388e 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -107,4 +107,13 @@ extern void __init_misc (int, char **, char **); #define DIAG_IGNORE_NEEDS_COMMENT(version, option) \ _Pragma (_DIAG_STR (GCC diagnostic ignored option)) +/* This mirrors the C11 max_align_t type provided by GCC, but it is + also available in C99 mode. The aligned attributes are required + because some ABIs have reduced alignment requirements for struct + and union members. */ +typedef struct { + long long ll __attribute__ ((__aligned__ (__alignof__ (long long)))); + long double ld __attribute__ ((__aligned__ (__alignof__ (long double)))); +} libc_max_align_t; + #endif /* _LIBC_INTERNAL */ -- 2.1.0