HPlogo HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 2 Storage and Alignment Comparisons

Data Type Size and Alignments

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

This section discusses storage sizes and alignment modes for the HP 9000 and HP Apollo systems as well as the VAX/VMS C, CCS/1000, and CCS/C 3000.

In all, there are a total of seven possible alignment modes which can be grouped into five categories as described in Table 2-1 “The Alignment Modes ”.

Table 2-1 The Alignment Modes

Alignment Mode

Description

HPUX_WORD, DOMAIN_WORD

HPUX_WORD is the native alignment for HP 9000 Series 300 and 400. DOMAIN_WORD is the native alignment for HP Apollo Series 3000 and 4000. The most restricted alignment boundary for a structure member is 2 bytes.

HPUX_NATURAL, DOMAIN_NATURAL

HPUX_NATURAL is the native alignment for HP 9000 workstations and servers and HP 3000 Series 900 and, therefore, is the default alignment mode. DOMAIN_NATURAL is the native alignment for HP Apollo Series 10000. The alignment of a structure member is related to its size (except for long double and long pointers), and the most restricted alignment boundary is 8 bytes.

HPUX_NATURAL_S500

HPUX_NATURAL_S500 is the native alignment for HP 9000 Series 500. The alignment of a structure member is related to its size, and the most restricted alignment boundary is 4 bytes.

NATURAL

NATURAL is an architecture-independent alignment mode for HP Series 300, 400, workstations and servers, and HP Apollo Series 3000, 4000, and 10000. In the NATURAL mode, alignment of a structure member is related to its size, the most restricted alignment boundary being 8 bytes. The difference between HPUX_NATURAL and NATURAL are a 1-byte versus 2-byte minimum structure alignment and size, and the bit-field rules. This alignment mode is recommended when portability is an issue, since this mode enables data to be shared among the greatest number of HP-UX and Domain (HP Apollo) systems.

NOPADDING

This mode does not arise from a particular architecture. The most restricted alignment is 1 byte. NOPADDING alignment causes all structure and union members and typedefs to be packed on a byte boundary, and ensures that there will be no full byte padding inside the structure. Bit-field members either are byte-aligned or aligned immediately following a previous bit-field member, except in rare cases described in the section "Alignments of Bit-Fields" below.

 

NOTE: With the exception of bit-fields, DOMAIN_WORD structure alignment is the same as HPUX_WORD structure alignment, and DOMAIN_NATURAL structure alignment is the same as HP_NATURAL structure alignment.

The alignment modes listed above can be controlled using the HP_ALIGN compiler pragma. See “The HP_ALIGN Pragma ” for a detailed description of this pragma. The NATURAL alignment mode should be used whenever possible. This mode enables data to be shared among the greatest number of HP-UX and Domain (HP Apollo) systems.

© Hewlett-Packard Development Company, L.P.