Page 1 of 1

fetchable assembler program with OS linkage

PostPosted: Thu Jul 07, 2016 6:03 am
by Pedro
How to do?

When I try
#pragma linkage(TEST3,OS,fetchable)    

I get:
WARNING CBC3508 PEDRO.MISC.SOURCE(TEST2):7                
Option os fetchable for #pragma linkage is not supported.  

But is there some trick to avoid binding the parts together into a composite load module?

Re: fetchable assembler program with OS linkage

PostPosted: Wed Jul 13, 2016 11:22 am
by steve-myers
I have been thinking about this for almost a week, and concluded - sorry - this is BS.

First, I could not decide if you are trying to use the pragma to define a program that is callable from JCL or it is calling a program using the JCL interface.

Case 1 -- you don't need the progma -

int mypgm(int argn, char **argc) ...

Look familar? The library pre parses the PARM text as though it was on a command line.

// EXEC PGM=thepgm,PARM='A B C'

argn = 4, argc[ 1 ] = A, and so on. I forget what argc[ 0 ] is set to, but it is set

Case 2. Now I don't do much mainframe C, but

struct osparm
 {
  int len; // I don't know, off hand, how to define a 16 bit int, but that's what you want
  char text[100];
 }

int routine( struct osparm);


Note: again, no pragma. What you need is already in the language.

Re: fetchable assembler program with OS linkage

PostPosted: Fri Mar 03, 2017 10:17 pm
by mwilliams
Hello,
I am a bit confused as to what we are trying to accomplish?
Is the intent to have a C program load and call an assembler program?
Or call an assembler sub-module from a C program which is statically linked in the composite load module.

The first problem is with the “#pragma linkage” options.
According to the z/OS C/C++ language manual, specifies only 2 parms – the identifier and the option.
As my understanding, a C program can only load & call Language Environment (LE) compliant executable module. In other words, C program does not directly support dynamically calling an assembler (none LE compliant) module.

Second, the context of “fetchable” is miss-leading in the linkage options. For example, based upon the description of “fetch” (function to get a load module) in the C/C++ run time reference manual, explains the proper use of the “fetchable” linkage parameter. Basically, for example if you have two standalone C programs, in which program “A” loads/executes program “B”, the source of program “B” contains linkage (progB, fetchable). Where progB is the function name that is designated as the entry point of load module associated with program B. However, as for program A, pragma linkage (identifier, OS) just specifies the standard “OS” calling convention.

Bottom line, if you need to call an assembler module which is statically linked in your “composite load module”, just specify “#pragma linkage(TEST3,OS)”.
However, it highly recommended that the “C” should call LE compliant modules.

But if you need to dynamically call an assembler from a C program, that’s totally different animal. Basically, that involves stubbing in a LE compliant assembler module which dynamically loads and executes a non-LE compliant (legacy) assembler module(s).