Article View: comp.bugs.4bsd
Article #96Taking the address of parameters
From: Spencer Garrett
Date: Tue, 19 Sep 1989 19:17
Date: Tue, 19 Sep 1989 19:17
31 lines
2013 bytes
2013 bytes
< .... In C, parameters to (non-prototyped) functions are widened,
< so that `char' and `short' both become `int'. On a VAX, when one writes
<
< f(x) char x; { char *p = &x; ... }
<
< one gets a pun from the actual parameter (which has been `sent in' on
< the stack as an int) to the desired parameter (a char), while on the
< 680x0, one gets a conversion. ...
< In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
I would call it a conversion either way, but only big-endian machines
need to muck with the address in the process. At least it's a
compile-time conversion, and doesn't cost any execution time on
either flavor of machine.
In article <45717@bbn.COM>, news@bbn.COM (News system owner ID) writes:
> I would add one further though to this: avoid expressions like the
> above f(x) like the plague. This will, regretably, work on Vax,
> 68xxx, etc. "normal processors", but will fail miserably on machines
> like a Pyramid where the first N arguments to a function are placed in
> a register window. Just go and try to take the address of a register
> :-(.
> -- Paul Placeway
> <pplaceway@bbn.com>, <paul@cis.ohio-state.edu>
Ah, but this is perfectly respectable C, and taking the address
of a register WORKS on a Pyramid for this very reason. The only
additional silliness you have to deal with is that consecutive
parameters aren't necessarily found at consecutive addresses,
since only certain types (and a limited number) are passed in
the registers (the rest go on the stack like any normal machine).
Technical Details
Message-ID:
<5740@quick.COM>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!uw-entropy!quick!srgReferences:
<199@infovax.UUCP> <DUPUY.89Sep16000855@cs.cs.columbia.edu> <45717@bbn.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!jarvis.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!uw-entropy!quick!srg From: srg@quick.COM (Spencer Garrett) Newsgroups: comp.bugs.4bsd Subject: Taking the address of parameters Message-ID: <5740@quick.COM> Date: 19 Sep 89 19:17:29 GMT References: <199@infovax.UUCP> <DUPUY.89Sep16000855@cs.cs.columbia.edu> <45717@bbn.COM> Organization: Quicksilver Engineering, Seattle Lines: 31