mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Paweł Dziepak" <pdziepak@quarnos.org>
To: Szabolcs Nagy <nsz@port70.net>
Cc: musl@lists.openwall.com
Subject: Re: [PATCH] add definition of max_align_t to stddef.h
Date: Sun, 4 May 2014 04:36:03 +0200	[thread overview]
Message-ID: <CALS3df1b_40tOi3X03go4B0PtpYBjBg3VUKsbAUaDXYWYBPvGA@mail.gmail.com> (raw)
In-Reply-To: <20140430214250.GI12324@port70.net>

2014-04-30 23:42 GMT+02:00 Szabolcs Nagy <nsz@port70.net>:
> * Pawel Dziepak <pdziepak@quarnos.org> [2014-04-30 22:23:01 +0200]:
>>
>> +TYPEDEF union { long double ld; long long ll; } max_align_t;
>
> this is wrong
>
> - ld and ll identifiers are not reserved for the implementation
> (you could name them _ld, _ll or __ld, __ll etc)

I will fix that. However, I must admit I don't see why members of the
union (or struct) have to use identifiers reserved for the
implementation. It's not like they can conflict with anything, isn't
it?

> and see previous max_align_t discussion
> http://www.openwall.com/lists/musl/2014/04/28/8
>
> - compiler implementations are non-conforming on some platforms
> (_Alignof returns inconsistent results for the same object type so
> reasoning about alignments is problematic, there are exceptions
> where this is allowed in c++11 but not in c11)
>
> - max_align_t is part of the abi and your solution is incompatible
> with gcc and clang (your definition gives 4 byte _Alignof(max_align_t)
> on i386 instead of 8)

The behavior of _Alignof on x86 is indeed quite surprising. I actually
don't see why 8 is the right value and 4 isn't - System V ABI for x86
doesn't mention any type with alignment 8. Anyway, I agree that it
would be a good thing to mach the definition gcc and clang use, i.e.
something like that:

union max_align_t {
    alignas(long long) long long _ll;
    alignas(long double) long double _ld;
};

> there is probably not much choice and musl will have to copy the
> silly definition used in gcc/clang making max_align_t not very
> useful (it does not reflect malloc alignment supported by the libc
> nor the object alignments supported by the compiler)

Well, alignments supported by the compiler may be different from the
alignments supported by the libc and that depends on how the
implementation supports extended alignments. max_align_t specifies the
greatest fundamental alignment which is guaranteed to be supported in
all contexts (i.e. it's at least as strict as the strictest alignment
required by fundamental types).

Paweł


  parent reply	other threads:[~2014-05-04  2:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30 20:23 Pawel Dziepak
2014-04-30 21:42 ` Szabolcs Nagy
2014-04-30 22:43   ` Rich Felker
2014-05-04  2:52     ` Paweł Dziepak
2014-05-04 11:42     ` Paweł Dziepak
2014-05-07  5:02       ` Jens Gustedt
2014-05-04  2:36   ` Paweł Dziepak [this message]
2014-05-04  5:02     ` Rich Felker
2014-05-06 10:35 Paweł Dziepak
2014-05-07  3:13 ` Rich Felker
2014-05-07  4:14   ` Luca Barbato
2014-05-07  4:29     ` Rich Felker
2014-05-07  5:12       ` Luca Barbato
2014-05-07 22:48         ` Rich Felker
2014-05-08 12:07           ` Luca Barbato
2014-05-08 14:25             ` Rich Felker
2014-05-07  9:28   ` Paweł Dziepak
2014-05-07 23:07     ` Rich Felker
2014-05-08 10:57       ` Szabolcs Nagy
2014-05-08 14:11         ` Rich Felker
2014-05-08 16:41       ` Paweł Dziepak
2014-05-08 17:41         ` Rich Felker
2014-05-08 18:45           ` Jens Gustedt
2014-05-08 19:11             ` Paweł Dziepak
2014-05-08 19:22               ` Jens Gustedt
2014-05-08 19:45           ` Paweł Dziepak
2014-05-08 20:02             ` Rich Felker
2014-05-08 20:45               ` Paweł Dziepak

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=CALS3df1b_40tOi3X03go4B0PtpYBjBg3VUKsbAUaDXYWYBPvGA@mail.gmail.com \
    --to=pdziepak@quarnos.org \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /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).