Within a Metal C application, AMODE 31 and AMODE 64 programs can
call each other.
To take advantage of the Metal C AMODE-switching support,
be aware of the following information:
- The called and calling programs must be in separate source files.
Mixing addressing modes within a single C source file is not supported.
- The save area format for the called program is determined by the
AMODE and ASC mode of the called program, that is, 72-byte for AMODE
31 programs, F4SA for AMODE 64 programs, F7SA for AR mode programs.
The ability for tracing the save areas chain will be interrupted across
AMODE switches.
- The parameter list is prepared according to the AMODE of the called
program, that is, 4-byte slots for AMODE 31 programs and 8-byte slots
for AMODE64 programs.
- It is the user's responsibility to ensure that all storage addresses
passed to the AMODE 31 functions are addressable by the AMODE 31 functions.
Because the save area and parameter lists are part of the caller's
DSA, the caller must have its DSA allocated in the below-the-bar storage.
- The AMODE of the called program can be specified by the new amode31
and amode64 type attributes. For detailed information, see amode31
| amode64 type attribute in z/OS XL C/C++ Language Reference.
- The calling program switches the addressing mode before the call
and switches back to its own addressing mode on return from the call.
- The implicit sizes of types long and pointer in
the function prototype are determined by the addressing mode of the
called program.
- The __ptr64 qualifier can be used to specify a 64-bit pointer
on an AMODE 31 program; the pointer cannot be dereferenced at the
AMODE 31 program.
Example of an AMODE31 program that
calls an AMODE64 program
In Figure 1, AMODE 31 program "main" in
a31.c makes calls to AMODE 64 programs a64a1 and a64a2 in a64a.c.
For the commands that compile and link a31.c and a64a.c, see Commands that compile and link applications that switch addressing modes.
Figure 1. AMODE31 program that calls
an AMODE64 programa31.c
long a64a1 (long j, int k, short s) __attribute__((amode64));
int a64a2 (long j, int k, short s) __attribute__((amode64));
int main () {
int a = 40;
return a64a1(99LL, a, 4) + a64a2(-120LL, -60, -18);
}
a64a.c
long a64a1 (long a, int b, short c) {
return -(a+b+c);
}
int a64a2 (long a, int b, short c) {
return -(a+b+c);
}