Pyramid's "non-standard" C compiler

Chris Torek chris at MIMSY.UMD.EDU
Wed Aug 2 02:41:55 AEST 1989


>In article <235 at massey.ac.nz> K.Spagnolo at massey.ac.nz (Ken Spagnolo) writes:
>>I refer to the fact that in Pyramid C, given 'struct x x;', a call to
>>function y() like 'y(x);' will pass to y() the entire structure x, rather
>>that just a pointer to x, as is the case with all other C compilers I know
>>about.  

Then all those other compilers are broken.  This practise went out of
style with Version 7 Unix.

The Berkeley and System V VAX C compilers pass structures by value (as
all C compilers must) by copying the entire structure onto the stack
before the function call, and popping it off afterward.

In article <13095 at polyslo.CalPoly.EDU> polyslo!hoyt at decwrl.dec.com (Sir Hoyt)
writes:
>Um, if memory servers me right, there is nothing in the
>C language the specifies how structures are to be passed.

It must be by value.  The exact mechanics of call-by-value are not
defined by C, as they tend to be machine dependent.

>What do we do? We bitch about the rotten code people write.
>Not all of the world is a Vax..... ( as the saying goes )

In my experience, the only code that ever failed on a Pyramid but
happened to work on a VAX was something from Imagen, which had some
code like the following:

	struct one_word_long {
		int	field;
	};

	f() { struct one_word_long foo; ... g(foo); }

	g(x) int x; { ... }

which is just plain wrong.  In this case, the simplest fix was to
change the caller (f()) to pass `foo.field' instead of `foo'.

The reason it failed on the Pyramid but worked on VAXen and Suns is
that the Pyramid has two stacks (control and data) and on the Pyramid,
all structure values were passed on the data stack, regardless of
structure size, while simple values (int, float, etc) were passed in
registers.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.sys.pyramid mailing list