COHERENT manpages

This page displays the COHERENT manpage for alignment [Alignment or packing of fields within a structure].

List of available manpages
Index


alignment -- Definition

Alignment or packing of fields within a structure

Alignment refers to the  fact that some microprocessors require the address
of a  data entity  to be aligned  to a numeric  boundary in memory  so that
address modulo number equals zero.   For example, the M68000 and the PDP-11
require  that   an  integer  be  aligned  along   an  even  address,  i.e.,
address%2==0.  In the MS-DOS world, this is called ``packing''.

Generally speaking,  alignment is a  problem only if you  write programs in
assembly language.   For C programs,  COHERENT ensures that  data types are
aligned properly under foreseeable conditions.  You should, however, beware
of copying  structures and of casting  a pointer to char to  a pointer to a
struct, for these could trigger alignment problems.

Processors react  differently to an  alignment problem.  On the  VAX or the
i8086, it  causes a program  to run more  slowly, whereas on  the M68000 it
causes a bus error.

See Also

#pragma,
data types,
ld,
Programming COHERENT

Notes

The  COHERENT preprocessor  instruction #pragma lets  you set  alignment to
conform to  Intel's Binary Compatibility Standard  (BCS).  For details, see
the Lexicon entry for #pragma.