-zalign

Specifies z/OS aggregate mapping and alignment rules.

-zalign affects the mapping of structure members. z/OS structure mapping rules use a "shift-to-align" algorithm to minimize compiler inserted pad bytes for the alignment requirement of structure members. This differs from the default Open PL/I structure mapping rules described in the Structure topic, which are compatible with other UNIX and Windows compilers for inter-language compatibility.

Attention: We recommended use of the -zalign option only when structure mapping is required to match z/OS structure mapping rules such as when reading files imported from the mainframe which contain record structures that have z/OS compiler-inserted (and possibly removed) pad bytes for alignment purposes.

Dependencies

-zalign implies:

  • -zfloat: Sets the default FLOAT BINARY single precision to 21 and the default FLOAT BINARY double precision to 53. The Open PL/I default is 23 and 52 respectively.
  • -zchar: Specifies that the default alignment attribute for the CHAR, CHAR VAR, GRAPHIC, GRAPHIC VAR, WIDECHAR, WIDECHAR VAR and PICTURE data types is unaligned. The Open PL/I default is aligned.

Notes

  • -zalign implies double-word alignment of AREA and double-precision FLOAT BINARY on Intel 32-bit systems (the Open PL/I and Intel native default alignment is word on Intel 32-bit systems).
  • If -zalign is used for the compilation of one module, we recommend that all modules in a given program be compiled as such for compatibility. Mixing --zalign with compilation units in the same program might work, but can be problematic if the modules compiled with -zalign are not self-contained.
  • For adjustable structures (having REFER-extents or non-constant sized members), the -zalign "shift-to-align" algorithm might cause more code to be generated to access structure members with non-constant offsets (seen in the -map listing as (-V-) under the Location Field). Depending on structure layout, the amount of code generated can be extensive as compared to code generated using the Open PL/I default mapping rules (when not using -zalign). To mitigate this, we recommend Compiler optimization be set to a minimum level of -opt 2.
Restriction: Structures with multiple REFER-extents could adversely affect compiler resources, resulting in a Compiler abort. If this happens, please contact Micro Focus Customer Care.

Examples

Structure Layout Example (Open PL/I default)

The following shows structure ST with size 8 bytes; member "C" is at offset 0 (byte alignment) and member "X" is at offset 4 (word alignment), with 3 compiler-inserted pad bytes between.

       1
       2      dcl 1 ST,
       3            2  C CHAR,
       4            2  X FIXED BIN(31);
       5

NAME             CLASS      SIZE      LOCATION    ATTRIBUTES

ST               BASED      8                    LEVEL 1 STRUCTURE
C               MEMBER      1         00000000   LEVEL 2 CHAR(1)
                            3         00000001    -pad-
X               MEMBER      4         00000004   LEVEL 2 FIXED BIN(31,0)

Structure Layout Example (-zalign)

The following shows structure ST with size 5 (8 bytes are allocated in memory); member "C" is at offset 0 (byte alignment) and member "X" is at offset 1 (word alignment). In this example each member is shifted by 3 bytes (OFFSET=3 as shown below) to properly align each member on its required boundary, thus minimizing (and in this case eliminating) compiler-inserted bytes. Effectively, the "shift-to-align" algorithm propagates pad bytes that fill natural alignment gaps between members toward the beginning of the structure. Pad bytes which have been shifted outside the structure (that is, preceding the first member) are known as "hang bytes".

       1
       2      dcl 1 ST,
       3            2  C CHAR,
       4            2  X FIXED BIN(31);
       5

NAME             CLASS      SIZE      LOCATION    ATTRIBUTES

ST               BASED      5                     LEVEL 1 STRUCTURE OFFSET=3
C               MEMBER      1         00000000    LEVEL 2 CHAR(1) UNALIGNED
X               MEMBER      4         00000001    LEVEL 2 FIXED BIN(31,0)