leech@alanine.cs.unc.edu (04/21/89)
I just finished porting cfront 1.2.1 to our new DECstation 3100s
(MIPS CPU). This was a relatively easy port. The size/alignment file
is exactly the same as a Sun-4. The only caveat is the treatment of
functions using <varargs.h>. As usual for non-stack oriented
machines, there is magic in the C compiler which recognizes varadic
functions and generates different code sequences. In this case, the
name 'va_alist' is recognized. Since cfront trashes this name, it
must be restored in the intermediate C source before compiling.
The only place this problem affects cfront directly is in
lib/stream/out.c:form(). First, form() must be modified to use
<varargs.h>. Here's how this looks in our source:
#if dgux | mips /* form() requires varargs on some machines */
#include <varargs.h>
char *form(va_alist)
va_dcl
{
char *format;
register char* buf = bfree;
if (max < buf+fld_size) buf = formbuf;
va_list args;
va_start(args);
format = va_arg(args, char *);
register ll = vsprintf(buf, format, args);
va_end(args);
if (0<ll && ll<cb_size) // length
;
else if (buf<(char*)ll && (char*)ll<buf+cb_size)// pointer to trailing 0
ll = (char*)ll - buf;
else
ll = strlen(buf);
if (fld_size < ll) exit(10);
bfree = buf+ll+1;
return buf;
}
#else
// form() supplied with cfront goes here. Not included in this posting.
#endif
Second, the following patch should be made to lib/mk/makefile:
replace the standard actions for compiling out.c with
# Kludged for DECstation 3100s (MIPS) so varargs works
# MIPS compiler recognizes 'va_alist' and generates magic code
# $(CC) $(CCFLAGS) -I../stream -c ../stream/out.c
out.o: ../stream/out.c
$(CC) $(CCFLAGS) -I../stream -Fc ../stream/out.c > out.c
sed -e 's/_au0_va_alist/va_alist/g' < out.c > out..c
cc -c out..c
mv out..o out.o
Similar code will be required for any user function using varargs.
Ideally, this patch would be made to the compiler, but this suffices
to get cfront & libC running.
--
Jon Leech (leech@cs.unc.edu) __@/
"A compact set can be controlled by a finite police force no
matter how dumb." H. Weyl ca. 1938
rose@tci.bell-atl.com (Bob Rose) (09/27/89)
We're trying to use C++ on a DECstation 3100. I've been told by the DEC people that they're working on a port of g++. In the meanwhile, does anyone know if Oasys, or any other company offers a c++ for the 3100? Remember, this is the DECstation, NOT VaxStation 3100. thanks, Bob Rose Technology Concepts Inc. Sudbury MA, 01776 rose@tci.bel-atl.com