Un-alignment in structures

Ron Natalie <ron> ron at brl-tgr.ARPA
Sun Mar 17 12:26:57 AEST 1985


> It is not accurate to say that the VAX has no alignment restrictions.  While
> a VAX can handle unaligned data, the performance penalty for doing so is
> significant.  Aligned data is almost always what you want.
> 
> Nevertheless, it wouldn't have killed the PCC-porters to include a
> command-line compiler option to turn off alignment for those rare cases when
> external unaligned data formats have to be matched....

I'd hardly say significant.  There are two peformance penalties to pay
for not having things longword aligned.  The first is that there is a
64 bit path in to memory.  Accesses that straddle the boundry, require
two fetches.  However, if a structure contains elements such that it
unevenly spans a longword boundry, it is unclear that padding the structure
out to the doubleword is going to do any good whatsoever.  The second
problem is that the compiler might make use of some tricks that require
longword alignment, but it doesn't.  Explicitly setting the pointers
to point to non standard alignments works just fine (this is how you
get around the moronic struct structure).

-Ron



More information about the Comp.lang.c mailing list