public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: John David Anglin <dave.anglin@bell.net>
To: Jason Merrill <jason@redhat.com>
Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Jeff Law <law@redhat.com>, Carlos O'Donell <carlos@redhat.com>
Subject: Re: [PATCH] Implement new hook for max_align_t_align
Date: Tue, 11 Oct 2016 20:04:00 -0000	[thread overview]
Message-ID: <519be582-d8e5-a6ef-f699-90a21250180b@bell.net> (raw)
In-Reply-To: <CADzB+2=XBG7d2Lp8UraKKYVjZzsEvxXM4tgVPN6ORn5ib=ztLQ@mail.gmail.com>

On 2016-10-11 2:50 PM, Jason Merrill wrote:
> /* Alignment, in bits, a C conformant malloc implementation has to
> provide.
>     The HP-UX malloc implementation provides a default alignment of 8
> bytes.
>     This can be increased with mallopt.  The glibc implementation also
> provides
>     8-byte alignment.  Note that this isn't enough for various POSIX
> types such
>     as pthread_mutex_t.  However, since we no longer need the 16-byte
> alignment
>     for atomic operations, we ignore the nominal alignment specified
> for these
>     types.  The same is true for long double on 64-bit HP-UX.  */
>
> If PA malloc doesn't actually provide 16-byte alignment, this change
> seems problematic; it will mean any type that wants 16-byte alignment
> will silently get 8-byte alignment instead.

I agree the situation is something of a mess.  On linux, we could bump 
the alignment
of malloc to 16-bytes.  However, Carlos argued that we don't need to and 
I think doing
so would be detrimental to performance.

The 16-byte alignment was used originally because the ldcw instruction 
used for atomic
operations in linux threads needs 16-byte alignment.  However, the nptl 
pthread
implementation now uses a kernel helper for atomic operations.  It only 
needs
4-byte alignment.  The largest alignment actually needed is for long 
double (8 bytes).
However, we can't change the 16-byte alignment without affecting the 
layout of various
structures.

The same is true for long double on HPUX.  Originally, it was planned to 
implement it
in hardware and that would have required 16-byte alignment.  It was only 
implemented
in software with an 8-byte alignment requirement.  Somehow, it ended up 
with 8 and
16-byte alignment in the HP 32 and 64-bit compilers, respectively. In 
both cases, malloc
has 8-byte alignment.  It is possible to increase the "grain" size of HP 
malloc to 16 bytes.

Thus, I don't think the silent reduction to 8-byte alignment matters.  
Without the change,
we are faced with spurious warnings from new.

--
  John David Anglin dave.anglin@bell.net

  parent reply	other threads:[~2016-10-11 20:04 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-08 17:01 Bernd Edlinger
2016-10-08 17:36 ` John David Anglin
2016-10-09  8:35   ` Bernd Edlinger
2016-10-09 17:52     ` John David Anglin
2016-10-10 18:21       ` John David Anglin
2016-10-11 18:51         ` Jason Merrill
2016-10-11 18:59           ` DJ Delorie
2016-10-11 20:12             ` Jason Merrill
2016-10-11 20:55               ` John David Anglin
2016-10-11 20:57                 ` Jakub Jelinek
2016-10-11 21:27                 ` Jason Merrill
2016-10-11 20:04           ` John David Anglin [this message]
2016-10-12  7:02             ` Carlos O'Donell
2016-10-12  7:25               ` Jakub Jelinek
2016-10-12  7:52                 ` Florian Weimer
2016-10-12  8:02                   ` Jakub Jelinek
2016-10-12 12:13                     ` John David Anglin
2016-10-12 12:33                       ` Bernd Schmidt
2016-10-12 12:43                         ` Richard Biener
2016-10-12 12:46                           ` Bernd Schmidt
2016-10-12 15:51                           ` Joseph Myers
2016-10-12 13:48                     ` Jason Merrill
2016-10-12 14:17                       ` John David Anglin
2016-10-12 19:59                         ` Carlos O'Donell
2016-10-12 16:14                     ` Jeff Law
2016-10-12 17:24                       ` John David Anglin
2017-02-25 17:46                         ` Gerald Pfeifer
2017-02-25 22:13                           ` John David Anglin
2017-02-25 22:46                             ` Gerald Pfeifer
2017-02-25 23:46                               ` John David Anglin
2016-10-12 18:01                       ` Florian Weimer
2016-10-12 18:13                         ` John David Anglin
  -- strict thread matches above, loose matches on Subject: below --
2016-10-08 16:43 Bernd Edlinger
2016-10-08 15:45 John David Anglin

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=519be582-d8e5-a6ef-f699-90a21250180b@bell.net \
    --to=dave.anglin@bell.net \
    --cc=bernd.edlinger@hotmail.de \
    --cc=carlos@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=law@redhat.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).