public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Joseph Myers <joseph@codesourcery.com>, gcc-patches@gcc.gnu.org
Cc: fweimer@redhat.com
Subject: Re: Make max_align_t respect _Float128
Date: Fri, 26 Aug 2016 21:51:00 -0000	[thread overview]
Message-ID: <56e04616-afd7-7fce-f2ba-00304ea5686b@cs.ucla.edu> (raw)
In-Reply-To: <alpine.DEB.2.20.1608262052110.1996@digraph.polyomino.org.uk>

On 08/26/2016 01:54 PM, Joseph Myers wrote:
> Such an increase is of course an ABI change, but a reasonably safe
> one, in that max_align_t doesn't tend to appear in library interfaces
> (rather, it's something to use when writing allocators and similar
> code;

It should be fine, though I would like to mention a thin-ice area. Emacs 
uses max_align_t to infer whether malloc returns a pointer that is a 
multiple of 8, with macros like this:

   // in src/lisp.h:
   #define GCALIGNMENT 8

   // in src/alloc.c:
   #define MALLOC_IS_GC_ALIGNED (__alignof__ (max_align_t) % GCALIGNMENT 
== 0)

If __alignof__ (max_align_t) is greater than malloc alignment, the 
assumption behind the above code is wrong, i.e., MALLOC_IS_GC_ALIGNED 
might return 1 even though the correct value is 0. As it happens, Emacs 
will work on x86 since GCALIGNMENT is 8; but if GCALIGNMENT were 
increased to 16 the definition of MALLOC_IS_GC_ALIGNED would become 
incorrect with the proposed GCC patch.

> (I think glibc malloc alignment should also increase to 16-byte on
> 32-bit x86 so it works for allocating objects of these types, which is
> now straightforward given the fix made for 32-bit powerpc.)

Yes. I hope the above note helps explain why malloc alignment should be 
at least max_align_t.

> OK to commit?

For what it's worth, it looks good to me.


[in your followup email]

> Well, the patch could use __SIZEOF_FLOAT128__ just as well as __i386__
> (the effect would be an extra union member

s/union/struct/. Though I've always wondered why it is a struct and not 
a union. Maybe change it to union while we're doing an ABI change anyway?

  parent reply	other threads:[~2016-08-26 21:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 20:55 Joseph Myers
2016-08-26 21:10 ` Marc Glisse
2016-08-26 21:30   ` Joseph Myers
2016-08-26 21:45 ` Florian Weimer
2016-08-26 21:57   ` Paul Eggert
2016-08-26 22:25   ` Joseph Myers
2016-08-26 21:51 ` Paul Eggert [this message]
2016-08-29 13:29   ` Marek Polacek
2016-08-29 15:40     ` Joseph Myers
2016-09-01 14:18 ` Ping " Joseph Myers
2016-09-05 17:07 ` Make max_align_t respect _Float128 [version 2] Joseph Myers
2016-09-06  9:06   ` Richard Biener
2016-09-06 11:26     ` Joseph Myers
2016-09-06  9:19   ` Florian Weimer
2016-09-06  9:24     ` Richard Biener
2016-09-07  7:45       ` Florian Weimer
2016-09-07 17:53         ` Joseph Myers
2016-09-08  9:35           ` Florian Weimer
2016-09-06 11:40     ` Joseph Myers
2016-09-06 15:06       ` Florian Weimer
2016-09-06 15:20         ` Joseph Myers
2016-09-06 15:59           ` Paul Eggert
2016-09-06 20:47             ` Joseph Myers
2016-09-06 21:41               ` Paul Eggert
2016-09-07  9:22                 ` Florian Weimer
2016-09-07 11:52                   ` Mark Wielaard
2016-09-08  1:58                     ` Paul Eggert
2016-09-08 11:58                       ` Mark Wielaard
2016-09-08 12:22                         ` Florian Weimer
2016-09-08 14:59                         ` Paul Eggert
2016-09-08 12:30                       ` Bernd Schmidt
2016-09-08 12:34                         ` Florian Weimer
2016-09-07  9:15               ` Florian Weimer
2016-09-06 21:03           ` Jason Merrill
2016-09-06 21:18             ` Joseph Myers
2016-09-06 21:53               ` Jason Merrill
2016-09-06 21:56                 ` Joseph Myers
2016-09-06 12:06     ` Bernd Schmidt
2016-09-06 14:59       ` Florian Weimer
2016-09-12 18:02   ` Make max_align_t respect _Float128 [version 3] Joseph Myers
2016-09-19 16:08     ` Ping " Joseph Myers
2016-09-19 17:11       ` Paul Eggert
2016-09-26 16:35       ` Jeff Law

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=56e04616-afd7-7fce-f2ba-00304ea5686b@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).