Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!oliveb!pyramid!prls!mips!mash From: mash@mips.UUCP Newsgroups: comp.lang.c Subject: Re: Function prototypes versus open() Message-ID: <441@winchester.UUCP> Date: Sat, 6-Jun-87 02:43:07 EDT Article-I.D.: winchest.441 Posted: Sat Jun 6 02:43:07 1987 Date-Received: Thu, 11-Jun-87 04:12:25 EDT References: <18346@ucbvax.BERKELEY.EDU> <8042@utzoo.UUCP> <2210@hoptoad.uucp> <5927@brl-smoke.ARPA> <2242@hoptoad.uucp> Reply-To: mash@winchester.UUCP (John Mashey) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 38 In article <2242@hoptoad.uucp> gnu@hoptoad.uucp (John Gilmore) writes: ..... >This might occur in a machine with overlapping register windows, such >as a Pyramid or various RISC machines. Typically, arguments would be >passed in registers, but for calls to vararg functions, they would get >pushed on a stack, or an argument count passed in secretly, or some >such... >I can see a few possible ways around this but they all involve making >the varargs interface pass arguments compatibly with the non-varargs.... >How do the Pyramid and MIPS compilers handle open() calls now? MIPS does the following: callee: the code is the same, regardless of whether the callee is vararg'd or not: 0-4 arguments are placed in registers args 5-? are placed onto the stack [not pushed, the stack doesn't move until the actual function call, if at all] space is left in the stack for args 1-4. (non-long args complexify all this, but that's the idea) caller: usually gets the args from the registers, or the stack, as needed saves any of args 1-4 into space reserved on the stack, if compiler "suspects" & operator being applied to the arguments, even indirectly, as in x = &arg2; z = *--x; varargs declaration makes sure that compiler suspects the right things! Thus, normal access to the variables is thru the registers, and the first 4 args are only saved into memory if they need to be, or if the compiler has reason to suspect they need to be. Statistically, the arguments almost NEVER get saved unless they really need to. -- -john mashey DISCLAIMER: UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!mash, DDD: 408-720-1700, x253 USPS: MIPS Computer Systems, 930 E. Arques, Sunnyvale, CA 94086