Flexible Handling of Unaligned Data

Depending on the specific Alpha processor(s) you are targeting, applications that perform operations on data that is not naturally aligned on a same-sized boundary (for example, longword on a longword boundary, and quadword on a quadword boundary) can either exhibit poor performance because of the additional processing required to handle the unaligned data, or cause the process to fault and terminate abnormally. You can improve the performance and quality of your applications by avoiding unaligned data operations when possible.

You can avoid alignment problems by disabling structure packing, for example, by using #pragma pack, and by avoiding unorthodox pointer operations such as casting a pointer. Structure packing should be used sparingly, if at all. When structure packing is necessary, however, you can use the pointer qualifier _ _unaligned to access packed data. In addition, on all Alpha systems, you can use the axpalign /enable command to help debug alignment problems in your code.

For a more thorough discussion of data alignment issues, see the Working with Data Alignment Issues section in Chapter 3.