mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: max_align_t mess on i386
Date: Sun, 15 Dec 2019 21:50:51 +0100	[thread overview]
Message-ID: <20191215205051.GX23985@port70.net> (raw)
In-Reply-To: <alpine.LNX.2.20.13.1912152232580.29076@monopod.intra.ispras.ru>

* Alexander Monakov <amonakov@ispras.ru> [2019-12-15 23:03:08 +0300]:
> On Sun, 15 Dec 2019, Rich Felker wrote:
> 
> > > It might violate the standard technically speaking, but I don't know of
> > > any examples of types smaller than 16 bytes that require 16 byte
> > > alignment.
> > 
> > It doesn't since no object can have size smaller than its alignment.
> > (As long as pointer types aren't lossy; if some pointer types lost low
> > bits, then it would be non-conforming.)
> 
> Yeah. I believe one usual concern is whether low bits may be expected to be
> zero in case one wants to carry a couple of bits along with the pointer.
> 
> On one hand, C doesn't say what it means for an arbitrary pointer to be
> suitably aligned for a particular type. On the other hand, in practice
> everyone assumes that it means that its value is divisible by alignment,
> and so on platforms with _Alignof(max_align_t) == 16, it means that low 4 bits
> of any address returned from malloc (including those with tiny allocated
> storage) will be zero.  Which makes those bit positions available for flags
> associated with the pointer, if you can arrange for them to be masked off
> to use the pointer itself.
> 
> (in principle a compiler could transform a program like that too, and unlike
> a programmer the compiler knows exactly what it means for a pointer to be
> aligned)
> 
> So if such use is accepted as valid, malloc needs to ensure alignment despite
> a small allocation size.

i think iso c is unclear, but that will change in c2x
which allows small alignment for small objects

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2293.htm


  reply	other threads:[~2019-12-15 20:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-14 15:19 Rich Felker
2019-12-14 17:51 ` Florian Weimer
2019-12-14 18:17   ` Rich Felker
2019-12-14 18:53     ` Daniel Kolesa
2019-12-15 18:04   ` Rich Felker
2019-12-15  5:47 ` Markus Wichmann
2019-12-15 18:06 ` Jeffrey Walton
2019-12-15 18:22   ` Rich Felker
2019-12-16 15:30     ` Jeffrey Walton
2019-12-16 15:56       ` Rich Felker
2019-12-16 16:36         ` Jeffrey Walton
2019-12-16 17:49           ` Rich Felker
2019-12-16 16:40         ` Florian Weimer
2019-12-16 17:45           ` Rich Felker
2019-12-16 17:49             ` Florian Weimer
2019-12-16 17:51               ` Rich Felker
2019-12-15 18:23   ` Joakim Sindholt
2019-12-15 18:51     ` Rich Felker
2019-12-15 20:03       ` Alexander Monakov
2019-12-15 20:50         ` Szabolcs Nagy [this message]
2019-12-15 21:51         ` Jeffrey Walton

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=20191215205051.GX23985@port70.net \
    --to=nsz@port70.net \
    --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).