29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Compiler</strong>-specific Features<br />

4.1.11 __packed<br />

The __packed qualifier sets the alignment of any valid type to 1. This means that:<br />

• there is no padding inserted to align the packed object<br />

• objects of packed type are read or written using unaligned accesses.<br />

The __packed qualifier applies to all members of a structure or union when it is declared<br />

using __packed. There is no padding between members, or at the end of the structure.<br />

All substructures of a packed structure must be declared using __packed. Integral<br />

subfields of an unpacked structure can be packed individually.<br />

Usage<br />

The __packed qualifier is useful to map a structure to an external data structure, or for<br />

accessing unaligned data, but it is generally not useful to save data size because of the<br />

relatively high cost of access. Only packing fields in a structure that requires packing<br />

can reduce the number of unaligned accesses.<br />

Note<br />

On <strong>ARM</strong> processors that do not support unaligned access in hardware, for example,<br />

pre-<strong>ARM</strong>v6, access to unaligned data can be costly in terms of code size and execution<br />

speed. Data accesses through packed structures must be minimized to avoid increase in<br />

code size and performance loss.<br />

Restrictions<br />

The following restrictions apply to the use of __packed:<br />

• The __packed qualifier cannot be used on structures that were previously declared<br />

without __packed.<br />

• Unlike other type qualifiers you cannot have both a __packed and non-__packed<br />

version of the same structure type.<br />

• The __packed qualifier does not affect local variables of integral type.<br />

• A packed structure or union is not assignment-compatible with the corresponding<br />

unpacked structure. Because the structures have a different memory layout, the<br />

only way to assign a packed structure to an unpacked structure is by a<br />

field-by-field copy.<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 4-11<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!