public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Haley <aph@redhat.com>
To: Maurizio Vitale <maurizio.vitale@polymath-solutions.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: aligned attribute
Date: Wed, 20 Dec 2006 13:37:00 -0000	[thread overview]
Message-ID: <17801.15520.429722.620134@zebedee.pink> (raw)
In-Reply-To: <5CB5CBCD-4D13-44B6-B84E-BBDF62F78DDF@polymath-solutions.com>

Maurizio Vitale writes:
 > But when I move to my real application (an event-driven simulator) I  
 > get stack allocated objects on 8-byte boundaries.
 > 
 > Now, my reading of the documentation is that the aligned attribute  
 > (when used for types, as in the example I gave) applies to all  
 > allocations (global, auto and heap). Is there any place where it is  
 > said otherwise? Regardless of the documentation, what does the  
 > implementation do?

You can't get alignment any greater than the alignment of the stack
pointer.  The alignment of the stack pointer is defined the the ABI of
the particular target you're using.  I think it's 16 for x86
processors, but the processor itself doesn't enforce that: it varies
across operating systems and processor variants.

 > This lead me to believe that every time a variable of type S is
 > allocated, the requested alignment is used (modulo linker
 > limitations of above).

Sure, but that only really applies to statically allocated objects.  I
guess no-one appreciated that someone might want to use it for
auto variables.

Andrew.

  reply	other threads:[~2006-12-20 13:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-20 13:28 Maurizio Vitale
2006-12-20 13:37 ` Andrew Haley [this message]
2006-12-20 13:52   ` Maurizio Vitale
2006-12-21 21:23     ` Tim Prince
2006-12-21 21:31       ` Maurizio Vitale
2006-12-22 12:02         ` Andrew Haley
2006-12-22 13:16           ` Maurizio Vitale
2006-12-21 21:21   ` Tim Prince

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=17801.15520.429722.620134@zebedee.pink \
    --to=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=maurizio.vitale@polymath-solutions.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).