All,

I encountered some strange things while porting a C-Module to z/OS that
needs to be called dynamically from a COBOL Program.

The C-Prog is made fetchable by coding

#pragma linkage(MYPROG,fetchable)

in the prog.

Now, when the C-Prog is CALLED, the passed parameters are received
correctly - just one parm, a pointer to a COBOL-struct. The pointer is
"received" correctly.

So far everything is well.

Within the C-Prog I've declared some static global variables, like this:


static int   FirstCall = 0;
static char *Ptr       = NULL;

int MYPROG(void *Parm)
{
   if(FirstCall == 0)
      FirstCall = printf("HELLO FROM MYPROG...\n");

   Ptr = malloc(1234); /* <- S0C4 here! */
   do_some_stuff();
   free(Ptr);

   return(0);
}


It seems there goes something wrong with addressing these variables. At
first, "FirstCall" isnt' initialized with "0". The malloc gives me a
S0C4, when the pointer of the malloced area is to be stored into "Ptr".
So I guess, that FirstCall doesn't contains "0" is because it is somehow
wrong addressed....


Any ideas? I'll add my Compiler and Linker settings....

Bye & Thanks,
Michael


Compiler-Options:

RENT
ILP32
STRICT
LANGLVL(EXTENDED)
ARCH(0)
TUNE(0)
SSCOMM
TARGET(LE)
SEARCH(//'SYS1.CEE.SCEEH.+')
LSEARCH(DD:USERLIB)
NOOPT
LONGNAME
SOURCE
ROSTRING
OBJECT
PLIST(HOST)
LOCALE(DE_DE.IBM-273)
EXECOPS
NOSTRICT_INDUC
NOWSIZEOF
NOSEQUENCE
NOMARGINS
NOINLINE
NOLIST
NOOFFSET
NOCOMPACT
NOCOMPRESS
NOIGNERRNO
NOINITAUTO
DEFINE(_OS390)
DEFINE(_OE_SOCKETS)
DEFINE(_LARGE_FILES)
DEFINE(_OPEN_THREADS)
DEFINE(_POSIX_SOURCE)
DEFINE(_ISOC99_SOURCE)
DEFINE(_UNIX03_SOURCE)
DEFINE(_XOPEN_SOURCE_EXTENDED=1)


Linker Options:

AMODE=31
RMODE=ANY
CASE=MIXED
REUS=RENT
UPCASE=NO
LIST
XREF
MAP

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to