Porting C from Sparc/UNIX to IBM 5000 series

  • Thread starter Jean-Claude ROVIER
  • Start date
J

Jean-Claude ROVIER

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

Thanks in advance.
--------------------
 
I

Ian Collins

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

A lot will depend on the dialect of "old-fashioned K&R C" the original
code is written in. One of the big problems with pre-standard compilers
is that they had their own standards!

I suggest try and compile the code with gcc, starting with its default
mode and then turning up the warnings. If you still have a Sparc box,
try compiling with Sun's cc and see what warnings you get. If the
original code was compiler with an old cc, you might be able to get it
to compiler with warnings.
 
E

Ersek, Laszlo

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS). I
don't have any idea about IBM mainframes and hence do not know about the
various C compilers on IBM. The C code I have is NOT ANSI C - it is
old-fashioned K&R C. Any insights on portability is appreciated.

Do you have the source to awkcc? If the original awk program is correct,
I'd rather hack on the generator. If there is a splotch in a C language
template used by the awkcc generator, you might have to fix it a thousand
times in the generated code during porting.

Of course if the original awkcc output (the generated C program) was
manually hacked...

lacos
 
E

Eric Sosman

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

I am not familiar with "awkcc," but if it is a translator that
reads awk source and emits C source to perform the task written in
awk, you will do far better to port the awk itself than to port
the C. The code generated by such translators is not designed for
portability and maintainability, nor even for readability. (This
is true, too, of C compilers that emit assembly language -- would
you try to port a C program by translating its assembly code from
SPARC to something else?)

Work with the awk source, not with the C/asm/whatever that a
particular awk implementation may have generated from it.
 
L

Lew Pitcher

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

Modern MVS systems no longer have K&R C compilers. The C compiler you'll use
on MVS will compile C89, and likely have a fair amount of C99 support.

Some caveats to watch for:
* MVS mainframes use EBCDIC characterset variants, while your Sparc/Unix
Awk-derived K&R C will likely assume ASCII. Since awk uses regexps, which
implies a wide range of characterset issues ([a-z] implies a contigious
set of values in ASCII, and a discontigious set in EBCDIC) that *will be
different* on MVS in EBCDIC, you will likely have a lot of
hand-correction to do to the awkcc-generated code.

* EBCDIC is a /family/ of charactersets, each one subtly different. The
family (as a whole) doesn't support the same character glyphs as ASCII,
and often supports glyphs with different values depending on the variant.
Since you are porting an awkcc-generated program, I presume that it takes
text input, and you will, by necessity, have a concern about *which*
EBCDIC the input text is recorded in.

* What am I thinking? Since certain commonly-used ASCII characters don't
exist in the EBCDIC-variant that your MVS C compiler will require source
to be written in, you will have to hand-correct your awkcc-generated code
to use *trigraphs* (or perhaps digraphs) to represent those characters.
Notably missing are the [ and ] glyphs, which are central to the coding
of C arrays.

* MVS C supports C89. While the C89 standard supports K&R as a "legacy"
format, you might find that the MVS C compiler in use /does not/ support
K&R. You will likely have a lot of hand-correction to do to the awkcc
generated code.

* MVS C filenames do not follow the format that Sparc/Unix dictates. If the
code opens named files, you will have to make changes to those filenames.
(i.e. FILE *fp = fopen("/etc/myconfig.conf","r"); becomes
FILE *fp = fopen("DDNAME:SYSCONF","r"); ).

* MVS data files are physically stored as "records", usually of fixed
length, and often of lengths greater than 80 bytes. The MVS C runtime
will "transform" 80-byte fixed-length data into a byte stream suitable
to be read with fgetc() et al. However, if your input data is recorded
in something other than 80-byte fixed-length records, you must fread()
and fwrite() it instead. Sorry, but that's the legacy of MVS, and there
isn't much you can do about it.


I'm sure that, if I put my mind to it, I could come up with more hints. But,
I think that I've given you enough hints for now.

You've bit off a pretty big chunk of work to do. Luck be with you.

HTH
 
L

Lew Pitcher

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

Modern MVS systems no longer have K&R C compilers. The C compiler you'll use
on MVS will compile C89, and likely have a fair amount of C99 support.

Some caveats to watch for:
* MVS mainframes use EBCDIC characterset variants, while your Sparc/Unix
Awk-derived K&R C will likely assume ASCII. Since awk uses regexps, which
implies a wide range of characterset issues ([a-z] implies a contigious
set of values in ASCII, and a discontigious set in EBCDIC) that *will be
different* on MVS in EBCDIC, you will likely have a lot of
hand-correction to do to the awkcc-generated code.

* EBCDIC is a /family/ of charactersets, each one subtly different. The
family (as a whole) doesn't support the same character glyphs as ASCII,
and often supports glyphs with different values depending on the variant.
Since you are porting an awkcc-generated program, I presume that it takes
text input, and you will, by necessity, have a concern about *which*
EBCDIC the input text is recorded in.

* What am I thinking? Since certain commonly-used ASCII characters don't
exist in the EBCDIC-variant that your MVS C compiler will require source
to be written in, you will have to hand-correct your awkcc-generated code
to use *trigraphs* (or perhaps digraphs) to represent those characters.
Notably missing are the [ and ] glyphs, which are central to the coding
of C arrays.

* MVS C supports C89. While the C89 standard supports K&R as a "legacy"
format, you might find that the MVS C compiler in use /does not/ support
K&R. You will likely have a lot of hand-correction to do to the awkcc
generated code.

* MVS C filenames do not follow the format that Sparc/Unix dictates. If the
code opens named files, you will have to make changes to those filenames.
(i.e. FILE *fp = fopen("/etc/myconfig.conf","r"); becomes
FILE *fp = fopen("DDNAME:SYSCONF","r"); ).

* MVS data files are physically stored as "records", usually of fixed
length, and often of lengths greater than 80 bytes. The MVS C runtime
will "transform" 80-byte fixed-length data into a byte stream suitable
to be read with fgetc() et al. However, if your input data is recorded
in something other than 80-byte fixed-length records, you must fread()
and fwrite() it instead. Sorry, but that's the legacy of MVS, and there
isn't much you can do about it.


I'm sure that, if I put my mind to it, I could come up with more hints. But,
I think that I've given you enough hints for now.

You've bit off a pretty big chunk of work to do. Luck be with you.

HTH
 
L

Lew Pitcher

HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

Modern MVS systems no longer have K&R C compilers. The C compiler you'll use
on MVS will compile C89, and likely have a fair amount of C99 support.

Some caveats to watch for:
* MVS mainframes use EBCDIC characterset variants, while your Sparc/Unix
Awk-derived K&R C will likely assume ASCII. Since awk uses regexps, which
implies a wide range of characterset issues ([a-z] implies a contigious
set of values in ASCII, and a discontigious set in EBCDIC) that *will be
different* on MVS in EBCDIC, you will likely have a lot of
hand-correction to do to the awkcc-generated code.

* EBCDIC is a /family/ of charactersets, each one subtly different. The
family (as a whole) doesn't support the same character glyphs as ASCII,
and often supports glyphs with different values depending on the variant.
Since you are porting an awkcc-generated program, I presume that it takes
text input, and you will, by necessity, have a concern about *which*
EBCDIC the input text is recorded in.

* What am I thinking? Since certain commonly-used ASCII characters don't
exist in the EBCDIC-variant that your MVS C compiler will require source
to be written in, you will have to hand-correct your awkcc-generated code
to use *trigraphs* (or perhaps digraphs) to represent those characters.
Notably missing are the [ and ] glyphs, which are central to the coding
of C arrays.

* MVS C supports C89. While the C89 standard supports K&R as a "legacy"
format, you might find that the MVS C compiler in use /does not/ support
K&R. You will likely have a lot of hand-correction to do to the awkcc
generated code.

* MVS C filenames do not follow the format that Sparc/Unix dictates. If the
code opens named files, you will have to make changes to those filenames.
(i.e. FILE *fp = fopen("/etc/myconfig.conf","r"); becomes
FILE *fp = fopen("DDNAME:SYSCONF","r"); ).

* MVS data files are physically stored as "records", usually of fixed
length, and often of lengths greater than 80 bytes. The MVS C runtime
will "transform" 80-byte fixed-length data into a byte stream suitable
to be read with fgetc() et al. However, if your input data is recorded
in something other than 80-byte fixed-length records, you must fread()
and fwrite() it instead. Sorry, but that's the legacy of MVS, and there
isn't much you can do about it.


I'm sure that, if I put my mind to it, I could come up with more hints. But,
I think that I've given you enough hints for now.

You've bit off a pretty big chunk of work to do. Luck be with you.

HTH
 
L

Lew Pitcher

Modern MVS systems no longer have K&R C compilers. The C compiler you'll
use on MVS will compile C89, and likely have a fair amount of C99 support.

Some caveats to watch for:
[snip]

One more thing: I briefly looked at awkcc, and it appears that it supplies a
Unix "library" archive file (libAWK.a) that needs to be static-linked to
the resulting program. libAWK.a seems to do all the heavy-lifting wrt
regular expressions, etc. Your MVS system won't have a libAWK.a, and the
libAWK.a you have for Sparc/Unix won't work on MVS. So, you're going to
have to find the source for libAWK.a, compile it on MVS, and generate an
MVS version of libAWK.a.

PS: Sorry about the multiple postings. My newsreader crashed while sending
my reply, and the automatic recovery sent the 2nd and 3rd version. I'll try
to not let that happen again.
 
T

Thomas David Rivers

Jean-Claude ROVIER said:
HELP NEEDED
-----------

I have the following problem:

I have C code generated from an AWk program using awkcc.

I need to port this C code to an IBM 5000 series mainframe (MVS).
I don't have any idea about IBM mainframes and hence do not know
about the various C compilers on IBM. The C code I have is NOT
ANSI C - it is old-fashioned K&R C. Any insights on portability
is appreciated.

Thanks in advance.


See our web site:

http://www.dignus.com

for information about a C compiler for the mainframe.

We've helped many people in your situation; hopefully
we'd be able to help out for this too!

- Dave Rivers -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top