From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4975 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 3/3] stddef: Define max_align_t Date: Mon, 28 Apr 2014 12:11:56 +0200 Message-ID: <20140428101156.GF12324@port70.net> References: <1398649434-23560-1-git-send-email-raj.khem@gmail.com> <1398649434-23560-3-git-send-email-raj.khem@gmail.com> <20140428020328.GV26358@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1398679941 9755 80.91.229.3 (28 Apr 2014 10:12:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Apr 2014 10:12:21 +0000 (UTC) Cc: Rich Felker To: musl@lists.openwall.com Original-X-From: musl-return-4979-gllmg-musl=m.gmane.org@lists.openwall.com Mon Apr 28 12:12:14 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WeiXi-00055Y-0a for gllmg-musl@plane.gmane.org; Mon, 28 Apr 2014 12:12:10 +0200 Original-Received: (qmail 18145 invoked by uid 550); 28 Apr 2014 10:12:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 18137 invoked from network); 28 Apr 2014 10:12:08 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4975 Archived-At: * Khem Raj [2014-04-27 22:51:34 -0700]: > On Sun, Apr 27, 2014 at 7:03 PM, Rich Felker wrote: > >> +typedef struct { > >> + long long __max_align_ll __attribute__((__aligned__(__alignof__(long long)))); > >> + long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); > >> +} max_align_t; > >> + > > > > As far as I can tell, there's no reason to use the attribute here. > > What's it there for? Also a union would probably be nicer than a > > struct, but perhaps it doesn't matter. > > union does not return correct alignment where as struct did. I just > tried to match > what clang also has > > http://reviews.llvm.org/rL201729 > nice.. i think i386 abi is non-conforming to the c11 alignment requirements now: long long has 8 byte alignment, but in a struct/union it has only 4 (this is why the attrs are needed above) long long x; // _Alignof(x) == 8 struct {long long x;} y; // _Alignof(y.x) == 4 i think the standard requires that all (addressable) long long objects should have the same alignment (or stricter) than _Alignof(x) max_align_t is defined to be the "greatest alignment supported in all contexts", i don't know why it is not just typedef char max_align_t __attribute__((aligned(__BIGGEST_ALIGNMENT__))); which gives 16 byte alignment on i386 gcc, i thought it was supported in all contexts if gcc and clang went with the same definition we should follow, but this makes the type less meaningful