This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

portable cdecl 'elliptic' function calls


Greetings!  On 3 of the 11 Debian architectures (i386, m68k, and ia64),
the cdecl calling convention is available, making the following code
possible:

object
c_apply_n(object (*fn)(), int n, object *x)
{object res=Cnil;
#if 1
 object *stack;

 if (!(stack=alloca(n*sizeof(*stack))))
   FEerror("Cannot allocate stack for elliptic call", 0);
 memcpy(stack,x,n*sizeof(*stack));
 res=fn();

As one might guess, this is taken from GCL and is used to call C
functions with a runtime-determined number of arguments.  

I know that the portable way to do this is with a switch statement on
n, but this would always be something of a workaround, limiting the
argument list to some presumably large number, and taking up a fair
bit of space in the code.

My question is whether there is an alternative call analogous to the
one outlined above for the other 8 Debian architectures (arm,
mips(el), alpha, hppa, sparc, ppc, s390), giving an unlimited to
within system stack memory runtime-determined argument list to a C
function call on these platforms as well?

Advice much appreciated, 

-- 
Camm Maguire			     			camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]