Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: edo@cis.ohio-state.edu (Eric Osborne)
Subject: Re: Sun C code compiled on OSF/1??
Date: 1995/07/21	[thread overview]
Message-ID: <3uomjgINNkmf@bumble.cis.ohio-state.edu> (raw)
In-Reply-To: 3umh4p$amh@agate.berkeley.edu

In article <3umh4p$amh@agate.berkeley.edu> hsiacc@prometheus.ME.Berkeley.EDU (Andy C. Hsia) writes:
>
>I'm trying to compile C code written for Sun computer on our Alpha 3000/600 
>running OSF/1 2.0.  At first, I got a few errors like the following:
>
>/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: redeclaration of 
>'random'; previous declaration at line 245 in file '/usr/include/stdlib.h'
> long random();
> -----^
>/usr/lib/cmplrs/cc/cfe: Error: t3m..c, line 141: Incompatible 
>function return type for this function
> long random();
> -----------^
>/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: redeclaration of 
>'calloc'; previous declaration at line 145 in file '/usr/include/stdlib.h'
> extern char *calloc();
> -------------^
>/usr/lib/cmplrs/cc/cfe: Error: t3m.c, line 145: Incompatible 
>function return type for this function
> extern char *calloc();
> -------------------^
>
These types of errors are common, in my experience, when porting code from
Sun machines. The Digital compilers enforce much tighter syntax checking than
at least some Sun compilers. 

>
>So I commented out the offending lines.  The code compiled with no
This is the correct thing to do. When you say you commented them out, I assume
you commented them in YOUR code, but not in the system header files. Commenting
them out in the header files would be very, very bad :-) .


>warnings or errors, but doesn't run properly.  When run, the program
>should say, "Starting analysis" and "The volume fraction is..."  My
>program, however, just says "Starting analysis," and doesn't go on.  A 'ps
>ux' shows that the program is utilizing 99% of the CPU, but no output.  A
>colleague successfully compiled (and run) the code on a Sun using ANSI C 
>(acc on Sun).  I successfully compiled (and run) the code on Ultrix 4.2 
>(using cc -O3 t3m.c -lm).
>

The first thing to check for is word size dependencies that are breaking
on the 64 bit Alpha architecture. You can use the 'lint -Q' command to find
and identify many/most of these. Word size dependencies, especially the
notion that you can put the contents of a pointer into an int, or that an
int and a long are the same size, are the single most common cause of errors
when porting code to Alpha machine. The C language definition essentially
states only that sizeof(short) <= sizeof(int) <= sizeof(long). Unfortunately,
most current architectures use 32 bits for the size of an int, long, and
pointer. That's been the case for so long that a lot of code takes it for
granted. Such code is broken, but since it will compile and run on about
everything except Alpha, most people immediately assume that something is
wrong with the Alpha system or compilers.

Word ordering and alignment errors are the other big bugaboo. Since you were
able to compile and run on Ultrix 4.2, the byte order issue probably isn't
getting you here.

If you're running on one of the newer versions of Digital UNIX, you should 
be able to compile your code with the -g option, then run it. When it goes
into the heavy CPU usage mode, you can use dbx to attach the process and
determine where the code is spending it's time. You can also run the program
from inside dbx.

In terms of general advice, that's about all I can offer without seeing the
code in question. You might also check Digital's Web page - 
http://www.digital.com - somewhere in there is a reference to a PostScript
file which contains a very nice guide on porting SunOS applications to
Digital UNIX (I think the guide actually still says DEC OSF/1).

Hope this helps.

Eric Osborne, who has ported a couple of million line of code to Alpha.
-- 
Eric D. Osborne	(614) 292-8018	|The Ohio State University
edo@cis.ohio-state.edu		|Department of Computer and Information Science
MIME Accepted   		|2015 Neil Ave. Columbus OH USA 43210



      parent reply	other threads:[~1995-07-21  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-07-20  4:00 Sun C code compiled on OSF/1?? Andy C. Hsia
1995-07-20  4:00 ` Mike Iglesias
1995-07-21  4:00 ` Mark Charette
1995-07-21  4:00 ` Eric Osborne [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox