Good information to know!  Thanks!!

________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of 
Farley, Peter x23353 <peter.far...@broadridge.com>
Sent: Friday, April 7, 2017 12:07 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Opinion: Using C "standard library" routines in COBOL.

Subsequent COBOL V5.2 testing showed that including CEESG003 at link/bind time 
also works for COBOL V5.2 dynamic call.  SYS1.SCEELKED is still required in 
STEPLIB/JOBLIB/LINKLIST for dynamic calls to work.

Thanks again to John M. for starting this discussion.  I love learning useful 
new ways to do our job!  TMTOWTDI even if not using Perl.

HTH

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Farley, Peter x23353
Sent: Friday, April 07, 2017 1:42 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Opinion: Using C "standard library" routines in COBOL.

My prior example, which did both a static and a dynamic call to CUSERID, was 
flawed because the statically linked version of CUSERID caused runtime 
initialization to happen which does not occur if there is no statically linked 
stub.

However, I found the solution to the problem.  In the link/bind step, include 
the following command in the SYSIN input at the appropriate place:

INCLUDE SYSLIB(CEESG003)

Static inclusion of a C library stub automatically pulls in this runtime 
routine, but if there is no library stub statically linked there is no 
reference to it and it is not pulled into the load module.

When CEESG003 is not included in the linked module, then R12+X'234' is zeroes 
at the time that the dynamically loaded CUSERID executes, resulting in a zero 
address in R15 and the subsequent S0C1 abend branching to low core (PSA 
location X'560' is also zeroes).

At the moment I do not know if this same INCLUDE works for COBOL V5+.  My 
testing so far has been only with COBOL V4.2.

Revised dynamic-only test program is as follows:

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    TSTCRUN.
       AUTHOR. P FARLEY.
      *REMARKS. PROGRAM TO TEST USING C RUNTIME LIBRARY ROUTINES.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  USERID-PLUS-1.
           05   USERID     PIC X(8).
           05   FILLER     PIC X.
       01  CUSERID-PTR     POINTER.
       01  CUSERID-PGM     PIC X(8) VALUE 'CUSERID'.
       PROCEDURE DIVISION.
       MAIN-PARA.
      *    DYNAMIC CALL, NEEDS HLQ.SCEELKED IN STEPLIB/JOBLIB/LINKLIST
      *    ALSO INCLUDE SYSLIB(CEESG003) IN THE LINK STEP
           MOVE SPACES TO USERID
           CALL CUSERID-PGM USING USERID-PLUS-1
               RETURNING CUSERID-PTR
           INSPECT USERID REPLACING ALL LOW-VALUE BY SPACE
           DISPLAY 'TSTCRUN'
               ': DYNAMIC CUSERID() RETURNED "' USERID '"'
           STOP RUN.

HTH

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of John McKown
Sent: Friday, April 07, 2017 12:39 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Opinion: Using C "standard library" routines in COBOL.

On Fri, Apr 7, 2017 at 10:59 AM, Frank Swarbrick < frank.swarbr...@outlook.com> 
wrote:

> Are all z/OS XL C/C++ RTL modules just stubs line this?  Or is it just
> some.?
>

I did a fast scan, as well as I could, and it sure seems to be most, if not 
all. Since they are vectoring to some table via GPR12, I would think this means 
that these routines are in some way managed by the LE system.
GPR12 is dedicated, in LE, to addressing the "Common Anchor Area" ( 
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.ceev100/caahd.htm
)
offset x'234' is the address of "C/370 Open libvec"
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.ceev100/ceelsa.htm

> ________________________________
> From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on
> behalf of Peter Hunkeler <p...@gmx.ch>
> Sent: Friday, April 7, 2017 12:19 AM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Re: Opinion: Using C "standard library" routines in COBOL.
>
> > The S0C1 is because SYS1.SCEELKED isn’t available for the dynamic calls.
>
> SCEELKED is intended to be used at linkedit/binder/ time, not
> execution time. What is statically linked is not the code for the C
> function, but only a little stub which finds the way to the code at
> runtime. In the case of CUSERID, this is:
>
>
>  L  15,X'234'(,12)
>  L 15,X'560(,15)
>  BR 15
>
> I see no danger of missing an update because static linking is used.
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to