gripe: variable arg lists

Spencer W. Thomas thomas at utah-gr.UUCP
Sat Nov 24 07:30:56 AEST 1984


In article <394 at ucsfcgl.UUCP> katzung at ucsfcgl.UUCP (Brian Katzung) writes:
>> But there is a standard method of dealing with variable argument lists.
>> 	#include <varargs.h>
>> The contents of the file differ from machine to machine, but the `entry points'
>> are standard.
>> 
>(I didn't see the original article so I'm not sure what was said.
>My apologies if I'm repeating something.)
>
>The "standard method" can't always be applied.  As far as I know, it
>is impossible to do under some implementations (I'd be delighted to
>have somebody prove me wrong by providing a non-trivial solution (ie,
>one that doesn't consist of separate entry points)).
>
>The problem arises on systems like ZILOG that put some arguments in
>registers (it may speed up execution a little, but it slows me
>down a lot).

The Pyramid is an example of a system that puts args in registers, but
they were perfectly able to write a "varargs" package.  The secret is a
little subroutine that knows where arguments are to be found and snarfs
up the first "n" of them from the registers and the rest from the stack
(or wherever), and builds a contiguous memory array of them.  Works
fine, and their implementation of sprintf (using varargs) runs fine on
their system, and on the Vax (the two places I've tried it).  I think
that with sufficient "cleverness", one can always get away with this
type of trick.

=Spencer



More information about the Comp.lang.c mailing list