IBM Enterprise Metal C for Z/OS, V3.1: Optimization and Programming Guide Part 1
Total Page:16
File Type:pdf, Size:1020Kb
IBM Enterprise Metal C for z/OS, V3.1 Version 3 Release 1 Optimization and Programming Guide IBM SC27-9402-00 Note Before using this information and the product it supports, read the information in “Notices” on page 221. This edition applies to Version 3 Release 1 of IBM® Enterprise Metal C for z/OS® (5655-MCE) and to all subsequent releases and modifications until otherwise indicated in new editions. Last updated: 2019-10-23 © Copyright International Business Machines Corporation 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document............................................................................................vii Where to find more information.................................................................................................................vii z/OS Basic Skills in IBM Knowledge Center......................................................................................... vii Technical support...................................................................................................................................... viii How to send your comments to IBM.........................................................................................................viii If you have a technical problem.......................................................................................................... viii Part 1. Coding: Advanced Topics............................................................................ 1 Chapter 1. z/OS 64-bit environment........................................................................................................... 3 Differences between the ILP32 and LP64 environments..................................................................... 3 ILP32 and LP64 addressing capabilities..........................................................................................3 ILP32 and LP64 data models and data type sizes...........................................................................3 Advantages and disadvantages of the LP64 environment.................................................................... 4 LP64 application performance and program size............................................................................ 4 LP64 restrictions...............................................................................................................................5 Migrating applications from ILP32 to LP64........................................................................................... 5 When to migrate applications to LP64............................................................................................. 5 Checklist for ILP32-to-LP64 pre-migration activities......................................................................5 Checklist for ILP32-to-LP64 post-migration activities....................................................................6 Using compiler diagnostics to ensure portability of code..................................................................... 6 Using the INFO option to ensure that numbers are suffixed...........................................................6 Using the WARN64 option to identify potential portability problems.............................................7 ILP32-to-LP64 portability issues...........................................................................................................7 IPA(LINK) option and exploitation of 64-bit virtual memory.......................................................... 8 Potential changes in structure size and alignment.......................................................................... 8 Data type assignment differences under ILP32 and LP64............................................................12 Pointer declarations when 32-bit and 64-bit applications share header files............................. 16 Potential pointer corruption........................................................................................................... 16 Potential loss of data in constant expressions.............................................................................. 17 Data alignment problems when structures are shared................................................................. 18 Portability issues with unsuffixed numbers...................................................................................19 Using a LONG_MAX macro in a sprintf subroutine........................................................................ 20 Programming for portability between ILP32 and LP64...................................................................... 20 Using header files to provide type definitions............................................................................... 20 Using suffixes and explicit types to prevent unexpected behavior...............................................21 Defining pad members to avoid data alignment problems........................................................... 21 Using prototypes to avoid debugging problems............................................................................ 22 Using a conditional compiler directive for preprocessor macro selection....................................22 Chapter 2. Reentrancy in Enterprise Metal C for z/OS..............................................................................23 Natural or constructed reentrancy...................................................................................................... 23 Limitations of constructed reentrancy for C programs..................................................................24 Controlling external static in C programs............................................................................................ 24 Controlling writable strings............................................................................................................ 24 Chapter 3. Using vector programming support.........................................................................................27 Options................................................................................................................................................. 27 Macro.................................................................................................................................................... 27 Vector data types................................................................................................................................. 27 iii Language extensions............................................................................................................................29 Vector literals..................................................................................................................................29 Initialization of vectors................................................................................................................... 32 typedef definitions for vector types............................................................................................... 32 Pointers........................................................................................................................................... 33 Unary expressions.......................................................................................................................... 33 Binary expressions..........................................................................................................................35 Cast expressions.............................................................................................................................45 Compound literal expressions........................................................................................................45 Other extensions for vector types.................................................................................................. 45 Vector built-in functions.......................................................................................................................45 Header file.......................................................................................................................................46 Summary of vector built-in functions.............................................................................................46 Arithmetic........................................................................................................................................54 Compare..........................................................................................................................................72 Compare Ranges.............................................................................................................................80 Find Any Element............................................................................................................................90 Gather and Scatter..........................................................................................................................98 Generate Mask..............................................................................................................................105 Copy until Zero..............................................................................................................................106 Load and Store..............................................................................................................................107