This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
portable cdecl 'elliptic' function calls
- From: Camm Maguire <camm at enhanced dot com>
- To: gcc at gcc dot gnu dot org,gcl-devel at gnu dot org, axiom-developer at nongnu dot org
- Date: Mon, 28 Jul 2003 17:34:08 -0400
- Subject: 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