mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>
Subject: Re: [PATCH 3/3] stddef: Define max_align_t
Date: Mon, 28 Apr 2014 12:11:56 +0200	[thread overview]
Message-ID: <20140428101156.GF12324@port70.net> (raw)
In-Reply-To: <CAMKF1soadO0O1T=aywFt97oV_4j51GJYsobG1jFNTmh53d=Otw@mail.gmail.com>

* Khem Raj <raj.khem@gmail.com> [2014-04-27 22:51:34 -0700]:
> On Sun, Apr 27, 2014 at 7:03 PM, Rich Felker <dalias@libc.org> 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


  reply	other threads:[~2014-04-28 10:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  1:43 [PATCH 1/3] bits/socket.h: Define SO_RCVBUFFORCE for mips Khem Raj
2014-04-28  1:43 ` [PATCH 2/3] Add soname to dynamic section Khem Raj
2014-04-28  2:00   ` Rich Felker
2014-04-28  5:02     ` Khem Raj
2014-04-28  5:54       ` Isaac Dunham
2014-04-28  6:00         ` Khem Raj
2014-04-28  6:22           ` Isaac Dunham
2014-04-28  6:32             ` Timo Teras
2014-04-28  7:20             ` Khem Raj
2014-04-28 14:28               ` Rich Felker
2014-04-28  1:43 ` [PATCH 3/3] stddef: Define max_align_t Khem Raj
2014-04-28  2:03   ` Rich Felker
2014-04-28  5:51     ` Khem Raj
2014-04-28 10:11       ` Szabolcs Nagy [this message]
2014-04-28 12:22         ` Jens Gustedt
2014-04-28 13:26           ` Szabolcs Nagy
2014-04-28 13:59             ` Jens Gustedt
2014-04-28 14:14             ` Rich Felker
2014-04-28 14:29 ` [PATCH 1/3] bits/socket.h: Define SO_RCVBUFFORCE for mips Rich Felker
2014-04-28 14:54   ` Khem Raj
2014-04-30 18:48     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140428101156.GF12324@port70.net \
    --to=nsz@port70.net \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).