-initcall

Causes the program being compiled to fetch and execute a call to the named routine before executing any procedural code.

At run time, the routine specified is called before any procedural code is executed.

Syntax

-initcall routine

Parameter

routine
The name of a routine to be fetched and executed before executing procedural code.

Example

The following command line shows how -initcall is used within an mfplx command:

mfplx -deb -defext -initcall DEBINIT foo.pli 

In this example, code is compiled such that the DEBINIT routine executes before the foo.pli program. The DEBINIT routine checks for memory corruptions as shown in the following code:

Note: (str) contains the name of the program being compiled, which in this case is foo.pli.
DEBINIT: proc(str);

  dcl str char(*);

  /* Variables for PLICTF */  
  dcl  EVENT_ERROR     fixed bin(31) static init(1000);
  dcl  LEVEL_DEBUG               fixed bin(31) static init(0);
  dcl  LEVEL_INFO                fixed bin(31) static init(1);
  dcl  LEVEL_WARNING             fixed bin(31) static init(2);
  dcl  LEVEL_ERROR               fixed bin(31) static init(3);
  dcl  TRACE_FLAGS_ALL           fixed bin(31) static init(-1);
  dcl  error_msg                 char(300) varying;
  
  /* Variables for Memory Validation */
  DCL _MFP_MEMVALID    entry(fixed bin(31) value, *) 
         returns(fixed bin(31)) options(nodescriptor);
      
  dcl  01 mem_validate_param,       
          05  cblte_mv_version   fixed bin(31) init(0), 
          05  cblte_mv_flags     fixed bin(31) init(0), 
          05  cblte_mv_type      fixed bin(31) init(0), 
          05  cblte_mv_size      fixed bin(31) init(0), 
          05  cblte_mv_address   poinTer init(NULL);                                                                                                                                              
  dcl  ret           fixed bin(31);

  
  on error
     begin;
       on error system;
       error_msg = "DEBINIT Error: " || trim(str) || ' :' ||  oncode();
       call PLICTF(EVENT_ERROR, LEVEL_ERROR, TRACE_FLAGS_ALL, error_msg, length(error_msg));     
       /* Continue processing   */
       /* don't want to take down user code because of bad initcall code! */       
       goto end_debcall;  
     end;

      ret = _MFP_MEMVALID(3, mem_validate_param);
      if (ret = 1000) then
        do;
          error_msg = "Memory Corruption detected: " || trim(str) || ' :' ||  hex(cblte_mv_address);        
          call PLICTF(EVENT_ERROR, LEVEL_ERROR, TRACE_FLAGS_ALL, error_msg, length(error_msg));               
        end;
  
  end_debcall:
  
end;