On 9/08/2016 11:01 AM, David Crayford wrote:
Not so easy to write as you might think. The COBOL LE environment
and the C/C++ LE environment are very different. Calling C/C++
runtime routines (other than the Metal C ones resident in the system,
but even some of those require some memory-allocation initialization)
requires that the C/C++ RTL environment be set up, but you do not
want to do that for every call, so you have to have at least a
name/token pair to save the (created once) C/C++ environment.
#pragma linkage(...,fetchable) takes care of the ILC linkage. LE will
dynamically load the C++ module and use the same LE environment for
both the COBOL and the C++ program. I've done this before for ILC
calls between HLASM->C++ and it works well. It's very fast, the call
overhead is just a few instructions in the FECB glue code.
I wrote a test with a COBOL main that calls a C++ subroutine
10,000,000 times. It ran in 01.33 CPU seconds, roughly the same as C++
calling a statically linked C++ routine.
It turns out that statically linking the C++ subroutine not only works
it's faster.
identification division.
program-id. cobilc.
data division.
working-storage section.
01 set-module-name pic x(8) value 'PCOLSET'.
01 stl-set.
05 stl-set-token pic x(4) value low-values.
05 stl-set-method pic x.
88 stl-set-method-new value 'N'.
88 stl-set-method-insert value 'I'.
88 stl-set-method-find value 'F'.
88 stl-set-method-update value 'U'.
88 stl-set-method-delete value 'D'.
88 stl-set-method-term value 'T'.
05 stl-set-key-length pic 9(8) binary.
05 stl-set-rec-length pic 9(8) binary.
05 stl-set-rec-ptr pointer.
procedure division.
perform 10000000 times
call "PCOLSET" using stl-set
end-perform
goback.
HTRT01I CPU (Total) Elapsed
CPU (TCB) CPU (SRB) Service
HTRT02I Jobname Stepname ProcStep RC I/O hh:mm:ss.th hh:mm:ss.th
hh:mm:ss.th hh:mm:ss.th Units
HTRT03I COBPSET C 00 144 00.33 00.86
00.33 00.00 7256
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN