Subject: Re: Question
To: Lennart Augustsson <augustss@cs.chalmers.se>
From: Matthew Jacob <mjacob@feral.com>
List: port-alpha
Date: 12/09/1998 08:38:25
On Wed, 9 Dec 1998, Lennart Augustsson wrote:

> 
> I have a question and no NetBSD-alpha to do a test run on.
> 
> Given an unaligned pointer to a struct on the alpha, is it
> possible to access a byte-sized field of the struct?
> Or do all struct pointers have to be aligned properly?

Of course it is possible to access byte-sized fields. The deal here is
that Alpha architecture (originally- newer versions are starting to allow
byte accesses- wimps!) allowed only 32 or 64 bit memory accesses, and
aligned naturally at that. The access to the byte quantities was then
accessed via shifts and register-register moves. Consider your register
set then to be a 29x64bit (32 registers, less the ZERO, RA and
PC) writeback cache.

If you have an unaligned pointer, and de-reference it, you'll get an
unaligned trap. I wasn't quite sure whether your question meant that you
wanted to access a byte sized object within a structure, or if you have a
pointer to an object you *know* is unaligned and still want to access it
as a structure. If the latter, then you probably need to do a byte copy
pullup of sorts to get it to an aligned state. Alternatively, if this is
in user space and you have the support for alignment fixups and either
don't mind the nagging kernel messages or turn them off, you can do that
too, but you'll be sorreee...


-matt