02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

the compilers supports the Altivec processor and the built-in DSP functions it<br />

provides. Your code should avoid the use of vector as a variable name.<br />

Statement Labels<br />

The ANSI specification requires labels to be associated with statements. It is not<br />

uncommon to place labels at the end of a code block without any associated<br />

statement at all. With strict ANSI checking this is an error. In the code below the<br />

default label is not connected to a statement. To correct this problem, either remove<br />

the label or add a null statement to give the label a proper point of connection.<br />

switch (xxx)<br />

{<br />

case X: statement;<br />

case Y: statement;<br />

default: /* WRONG – no statement here */<br />

}<br />

Summary of Compiler Macros<br />

For each supported C toolchain, the macros described in this section are defined<br />

when vxWorks.h is included in your compilation.<br />

_WRS_PACK_ALIGN(n)<br />

This macro is used to specify the packing and alignment attributes for a structure.<br />

Packing insures that no padding is inserted and that the minimum field alignment<br />

within the structure is one byte. The user can specify the assumed alignment for<br />

the structure as a whole with the argument x, in bytes. The value x is expected to<br />

be a power of two value (1,2,4,8,…). The size of the structure is then a multiple of<br />

this value. If the overall structure alignment is 1, the compiler assumes that this<br />

structure, and any pointer to this structure, can exist on any possible alignment.<br />

For an architecture that cannot handle misaligned data transfers, the compiler is<br />

forced to generate code to access each byte separately and then to assemble the<br />

data into larger word and longword units.<br />

The macro is placed after the closing brace of the structure field description and<br />

before any variable item declarations, or typedef name declarations.<br />

168

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!