Supplying your own prolog and epilog code

If you need the prolog and epilog code to provide additional functionality, you can use #pragma directives to instruct the compiler to use your own HLASM prolog and epilog code. Figure 1 provides an example.
Figure 1. Specification of your own prolog and epilog code for a function
   #pragma prolog(foo,"MYPROLOG")
   #pragma epilog(foo,"MYEPILOG")
   int foo() {
     return 0;
   }

To apply the same prolog and epilog code to all your functions in the C source file, use the PROLOG and EPILOG compiler options. When you use the PROLOG and EPILOG compiler options, by default, your prolog and epilog code is applied only to the functions that have external linkage. To apply your prolog and epilog code to all functions defined in the compilation unit, use the new "all" suboption provided by z/OS® V1R11 XL C compiler. For detailed information, see PROLOG and EPILOG options in z/OS XL C/C++ User's Guide.

The string you supplied to the PROLOG/EPILOG options or the #pragma directives must contain valid HLASM statements. The compiler does not validate the content of the string but it does take care of some formatting for you:
Your prolog code needs to ensure that:
Your epilog code needs to ensure that:
Your prolog and epilog code does not need to perform the following functions:
Start of change

User reserved DSA space

User reserved DSA space can be enabled by using the compiler option DSAUSER(value). If DSAUSER is specified without suboption, a user field with the size of a pointer is reserved on the stack. The user field is a 4-byte field for AMODE 31 and an 8-byte field for AMODE 64. This user field can be utilized by your prolog or epilog code.

If a value suboption is specified with DSAUSER, a user field with the size of value 32-bit words is allocated. Specifying DSAUSER with a suboption requires ARCH(6). The value must be an integer in the range of 0 to 50.

The user field can be located by the HLASM global set symbol &CCN_DSAUSER, which provides the offset to the user field. The compiler allocates the field on the stack only, without initializing it.

The following example shows how &CCN_DSAUSER is set by the compiler:
&CCN_DSAUSER SETC '#USER_2-@@AUTO@2'
The following example shows how &CCN_DSAUSER can be used in your prolog code:
STG 0,&CCN_DSAUSER.(,13)

For detailed information about the DSAUSER compiler option, see the topic about DSAUSER and NODSAUSER in z/OS XL C/C++ User's Guide.

End of change