EasyManua.ls Logo

Intel i960 - Inquiring about Alignment

Intel i960
347 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
i960 Processor Compiler User's Guide
7-48
7
Inquiring about Alignment
The keyword __alignof__ allows you to inquire about how an object is
aligned, or the minimum alignment usually required by a type. Its syntax
is just like
sizeof.
For example, the target machine requires a
double value to be aligned on
an 8-byte boundary, then
__alignof__ (double) is 8. This is true on the
i960 processor.
When the operand of
__alignof__ is a lvalue rather than a type, the
value is the largest alignment that the lvalue is known to have. It may
have this alignment as a result of its data type, or because it is part of a
structure and inherits alignment from that structure. For example, after
this declaration:
struct foo { int x; char y; } foo1;
the value of __alignof__ (foo1.y) is 4, the same as __alignof__
(int), even though the data type of foo1.y does not itself demand any
alignment.
Inline Functions Are as Fast as Macros
By declaring a function inline, you can direct the compiler to integrate
that function's code into the code for its callers. This makes execution
faster by eliminating the function-call overhead; in addition, if any of the
actual argument values are constant, their known values may permit
simplifications at compile time so that not all of the inline function’s code
needs to be included.
To declare a function inline, use the
inline keyword in its declaration.
For gcc960, use either
inline or __inline. For ic960, use __inline.
For example:
inline int
inc (int *a)
{
(*a)++;
}

Table of Contents

Related product manuals