The __align keyword instructs the compiler
to align a variable on an n-byte
boundary.
__align is a storage class modifier. It
does not affect the type of the function.
Syntax
__align(n)
where:
n
is the alignment boundary.
For local variables, n can
take the values 1, 2, 4, or 8.
For global variables, n can
take any value up to 0x80000000 in powers of 2.
Usage
__align(n) is
useful when the normal alignment of the variable being declared
is less than n. Eight-byte
alignment can give a significant performance advantage with VFP
instructions.
__align can be used in conjunction with extern and static.
Restrictions
Because __align is a storage class modifier,
it cannot be used on:
types,
including typedefs and structure definitions
function parameters.
You can only overalign. That is, you can make a two-byte object
four-byte aligned but you cannot align a four-byte object at 2 bytes.
Examples
__align(8) char buffer[128]; // buffer starts on eight-byte boundary
void foo(void)
{
...
__align(16) int i; // this alignment value is not permitted for
// a local variable
...
}
__align(16) int i; // permitted as a global variable.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.