The only way a COBOL routine can call an XPLINK-compiled routine
is if the caller is compiled with the Enterprise COBOL for z/OS® or COBOL for OS/390® & VM compiler with the DLL compiler
option, and the target of the call is in a separate DLL, or vice versa.
COBOL Dynamic Call to XPLINK is not supported.
Since XPLINK compatibility is only provided to Language Environment-conforming
languages, OS/VS COBOL programs and VS COBOL II programs are not supported
in an XPLINK(ON) environment.
The COBOL reusable environment support (the RTEREUS runtime option
or the callable interfaces ILBOSTP0 and IGZERRE) cannot be used in
an XPLINK(ON) environment.
COBOL ILC with an XPLINK function
in a separate DLL can employ either of two parameter passing techniques:
- The "pragmaless" style, where the COBOL programmer explicitly
specifies syntax indicating that arguments are to be passed BY VALUE,
and uses RETURNING syntax to access C function results.
RETURNING
values and BY VALUE arguments are implemented using pre-XPLINK C linkage
conventions, and are designed to enable pragma-less ILC with C or
with C++ using EXTERN C. This technique also works with XPLINK. In
this case, the glue code will load the necessary XPLINK parameter
registers when called from a COBOL function, or store them into the
argument area when calling a COBOL function.
- The #pragma linkage(..., COBOL) style, where the COBOL programmer
specifies normal BY REFERENCE argument conventions, the C functions
specify normal C by-value conventions, and the XL C/C++ compiler introduces
code to accommodate both.
An XPLINK program can identify a called
function as using a COBOL-style parameter list (R1 => list of addresses,
with the High Order Bit (HOB) of the last parameter turned on):
#pragma linkage(called_rtn,COBOL)
In
this case the XPLINK compiler generates a list of addresses to the
actual parameters. The only difference is that XPLINK loads up to
the first three of these addresses into registers 1, 2, and 3. When
the glue code receives control from the XPLINK caller to swap the
stack before giving control to the called COBOL function, it also
creates a complete by-reference parameter list and set register 1
with the address of this parameter list.
An XPLINK function
can also specify that it receives COBOL-style parameters as input:
#pragma linkage(this_rtn,COBOL)
Processing
via glue code is similar – when the XPLINK function receives control,
the first three parameter addresses have been loaded into the parameter
registers.