Article View: gnu.gcc.help
Article #42052Re: BIT Fields
From: Barnacle Wes
Date: Wed, 17 Jan 1996 00:00
Date: Wed, 17 Jan 1996 00:00
36 lines
2294 bytes
2294 bytes
Paul Repper wrote:
[...]
> 16k byte pages of memory are allocated in which structures will be stored.
> While accessing structures within the allocated pages, I receive a
> "BUS fault (alignment error)". The fault seems to occur anytime the
> structure is aligned on an odd byte. We are also unable to access the
> bit fields even if they are aligned on an even address.
>
> There are two situations which we believe contribute to the problems being
> experienced:
> 1. We cannot globally pack structures on 1-byte alignments.
> We can pack individual structures i.e.
> typedef struct x {...} __attribute__((packed)) X;
> but this does not seem to cure the problem either.
> 2. We cannot access structures or bit-fields aligned on odd- or
> even-bytes.
SPARC processors cannot access 16- and 32-bit objects at odd addresses.
I believe that all memory objects larger than a byte must be on an
even 4-byte boundary in fact, making 16-bit values of limited use.
Structure packing for *all* SPARC compilers will, of course, be
constrained to these requirements.
You have one of two ways to solve this problem: if the "memory footprint"
of the structure *must* be identical to the x86 version, you can pack/
unpack the structures into "native" SPARC structures before/after using.
If the memory footprint is not important, just use a structure with the
same C language elements as the x86 version, and let the compiler place
the bits where the SPARC wants them.
--
Wes Peters | Yes I am a pirate, two hundred years too late
Softweyr | The cannons don't thunder, there's nothing to plunder
Consulting | I'm an over forty victim of fate...
wes@intele.net | Jimmy Buffet
Technical Details
Message-ID:
<30FD5D1E.41C67EA6@intele.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<DKxGGD.1w9@esseye.si.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,3ceff2f7df0351a7 X-Google-Attributes: gid11318c,public From: Barnacle Wes <wes@intele.net> Subject: Re: BIT Fields Date: 1996/01/17 Message-ID: <30FD5D1E.41C67EA6@intele.net> X-Deja-AN: 135886125 references: <DKxGGD.1w9@esseye.si.com> to: Paul Repper <repper@esseye.si.com> content-type: text/plain; charset=us-ascii organization: The briney, briney deep mime-version: 1.0 newsgroups: gnu.gcc.help x-mailer: Mozilla 2.0b5 (X11; I; FreeBSD 2.1.0-RELEASE i386)