Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: macro at linux-mips.org (Maciej W. Rozycki)
Subject: Getting rid of Unaligned Accesses (UA)
Date: Thu, 22 May 2008 21:24:14 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.55.0805222104160.13339@cliff.in.clinika.pl> (raw)
In-Reply-To: <4835C5D8.6070708@hp.com>

On Thu, 22 May 2008, Jay Estabrook wrote:

> >  It might be a good question to ask at a GCC list.
> 
> Well, I tried asking one Alpha GCC guru, but never got a reply; I've
> been reluctant to try them all, so I tried here first... ;-}

 This is what the list is for -- if somebody feels like willing to
investigate the problem, they will reply.  At the very worst you will be
ignored, which may be annoying, but not exactly a disaster either (it
happened for me in the past too, yet I am still alive :-) ).

> >  How's vp defined?
> 
> Pointer to a UNION of different datatypes, so the pointer may be asked
> to point to anything from a char to a double.

 Then GCC is allowed to assume the alignment of the data pointed to will
be that of the member of the union requiring the largest.  And will
eagerly do so. ;-)

> >  Well, __attribute__((packed)) used to be the usual way to ask GCC to
> > assume the worst when it comes to alignment while keeping the data size
> > intact.  It has worked for years and if it got broken at any point, then
> > it is a bug in GCC.
> 
> Doesn't the "packed" normally get applied to a struct?

 Both struct and union definitions.

> In this case, since it's a UNION, what would "packed' mean?

 With such a definition in scope:

union { int i; } __attribute__((packed)) *foo;

accesses to foo->i will be treated as unaligned by GCC.  Verified to work
correctly with my Alpha/Linux-targeted cross-compiler which is 4.1.2 too,
except self-built, as you can imagine. ;-)

  Maciej



  reply	other threads:[~2008-05-22 20:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-22 18:53 Getting rid of Unaligned Accesses (UA) Jay.Estabrook
2008-05-22 19:10 ` macro
2008-05-22 19:13   ` Jay.Estabrook
2008-05-22 20:24     ` macro [this message]
2008-05-22 22:30       ` netbeans
2008-05-23 13:54         ` Jay.Estabrook
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox