In 64-bit data models, pointer sizes are always 64 bits. There
is no standard language syntax for specifying mixed pointer size.
However, it might be necessary to specify the size of a pointer type
to help migrate a 32-bit application (for example, when libraries
share a common header between 32-bit and 64-bit applications).
The z/OS XL C/C++ compiler reserves two pointer size qualifiers:
The size qualifier __ptr64 is not currently used;
it is reserved so that a program cannot use it. The size qualifier __ptr32 declares
a pointer to be 32 bits in size. This is ignored under ILP32.
Table 1. Examples of pointer
declarations that can be made under LP64int * __ptr32 p; /* 32-bit pointer */ 1 , 3 |
int * r; /* 64-bit pointer,
default to the model's size */ 4 |
int * __ptr32 const q; /* 32-bit const
pointer */ 1 , 2 , 3 |
Notes: - The qualifier qualifies the '*' before it.
- q is a 32-bit constant pointer to an integer.
- When __ptr32 is used, the program expects that
the address of the pointer variable is less than or equal to 31 bits.
You might need to ensure this by calling a special runtime function,
such as the Language Environment runtime function __malloc31.
You can call __malloc31 whenever you use your own
assembler routine to get storage, and want to keep the addresses in
structures and unions to a length of four bytes.
- If a pointer declaration does not have the size qualifier, it
defaults to the size of the data model.
|