__static_reinit() — CWI to reinitialize writable static area

The __static_reinit() function reinitializes the writable static area (WSA) of a dynamic link library (DLL). When a DLL is loaded, Language Environment performs static initialization of the WSA. Additionally, C++ static constructors are run during initialization. When a DLL is deleted, C++ static destructors are run and atexit routines are unregistered from the atexit list during termination.

Syntax

#include <edcwccwi.h>

int __static_reinit (int func_code, void *fcn);

int func_code
func_code performs termination/initialization and should be __STATIC_REINIT_FULL.
void *fcn
fcn is a DLL handle pointer returned from a previous successful call to the dlload() or dlopen() function..
__static_reinit() returns the following values:
  • If successful, returns 0.
  • If unsuccessful, __static_reinit() returns -1 and sets errno to one of the following values:
    EFAULT
    Occurs if the fcn address is not valid.
    EINVAL
    Occurs if fcn is not a valid DLL handle pointer or if func_code is not valid.
Usage Notes:
  1. __static_reinit() cannot be used with a DLL that is already in use.
  2. __static_reinit() can only be used with a DLL that has been explicitly loaded once.
  3. If a DLL (A) is loaded and Language Environment loads another DLL (B), B still exists if A is reinitialized.
  4. The __static_reinit() service should not be used while any other DLL is being initialized.
  5. The Vendor Interfaces header file, <edcwccwi.h>, is located in member EDCWCCWI of the SCEESAMP data set. To include <edcwccwi.h> in an application, the header file must be copied into a partitioned data set or a UNIX file system directory in which the z/OS® XL C/C++ compiler will find it.
  6. Figure 1 shows an example of how to use this CWI.
    Figure 1. Example of using __static_reinit
    ...
    /* Open a dynamic library and then reinitilizes its WSA*/
    
    #include <edcwccwi.h>
    #include <dlfcn.h>
    
    void *handle;
    int eret;
    
    handle = dlopen("mylib.so", RTLD_LOCAL | RTLD_LAZY);
    ....
    eret =  __static_reinit(__STATIC_REINIT_FULL, handle);