The system scope initialization and termination functions
The __tpf_module_init and __tpf_module_initRC initialization functions and the __tpf_module_term and __tpf_module_termRC termination functions define the system scope initializer.
The __tpf_module_initRC initialization function and the __tpf_module_termRC termination function have return codes.
void __tpf_module_init(void);
void __tpf_module_term(void);
int __tpf_module_initRC(void);
int __tpf_module_termRC(void);extern "C" void __tpf_module_init(void);
extern "C" void __tpf_module_term(void);
extern "C" int __tpf_module_initRC(void);
extern "C" int __tpf_module_termRC(void);The z/TPF system view
of writable data is modified when a CSO is initialized
by using the system scope initializer functions. On return from the__tpf_module_init function,
the writable data in the CSO is copied
to the z/TPF system view
of the CSO.
The MOVEC system macro updates the writable data in the SVM, which
includes the initialized and uninitialized static data sections. To
view the contents, use the binary tool readelf
The __tpf_module_term can be used to free up the resources obtained by using the __tpf_module_init function. Before the CSO is removed from memory, the __tpf_module_term function runs a unique process that corresponds to the system scope initialization by handling the termination clean up, such as the release of any system heap storage that was acquired. The __tpf_module_term function runs only if the system scope initialization and termination is successful.
If the system scope initialization is not successful, the __tpf_module_term function is not run and the system heap storage that was acquired can be lost. In this case, the z/TPF system issues an OLDR5270E message and the CSO is removed from memory. If the z/TPF system requires a restart or a catastrophic error occurs, the __tpf_module_term function does not run and data that was filed can be lost. Use z/TPF globals when filing data.
Table 1 contains the return conditions, the descriptions of return codes, and the z/TPF system actions. Use the information in this table as a guide when you code the system initializer.
| Return condition | Description of return code | z/TPF system action |
|---|---|---|
| No return code from the __tpf_module_init initialization function | The __tpf_module_init initialization function does not send a return code. | The z/TPF system assumes that the initializer is completed successfully and processing continues. The z/TPF system copies the writable static from the ECB virtual memory (EVM) to the system virtual memory (SVM). |
| Return code 0 from the __tpf_module_initRC initialization function | The initializer is completed successfully. | The z/TPF system assumes that the initializer is completed successfully and processing continues. The z/TPF system copies the writable static from the ECB virtual memory (EVM) to the system virtual memory (SVM). |
| Return code 1 from the __tpf_module_initRC initialization function | The initializer cannot be run now, and the program is marked as unusable. However, the first system call was not marked as complete, so the next call to the program tries to run the initializer again. This return code is valid only for initializer but not for terminator, and is used when a program with an initializer is called too early in restart processing. If the initializer returns 1 when the initializer is run for a program in a loadset that is being activated, treat 1 the same as -1. The loadset activation is terminated. | The z/TPF system takes
one of the following actions:
|
| Return code -1 from the __tpf_module_initRC initialization function | An error occurs. The initializer is not completed successfully, and the program is marked as unusable. | The z/TPF system takes
one of the following actions:
|
| ECB exits from a constructor | None. | The z/TPF system takes
one of the following actions:
|
For more information about the binary tool readelf,
see the GNU website.