This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Axiom-developer] portable cdecl 'elliptic' function calls
- From: Arthur Norman <acn1 at cam dot ac dot uk>
- To: Camm Maguire <camm at enhanced dot com>
- Cc: gcc at gcc dot gnu dot org, gcl-devel at gnu dot org, axiom-developer at nongnu dot org
- Date: Tue, 29 Jul 2003 07:50:18 +0100 (GMT Daylight Time)
- Subject: Re: [Axiom-developer] portable cdecl 'elliptic' function calls
- References: <E19hFdA-0003kJ-00@intech19.enhanced.com>
On Mon, 28 Jul 2003, Camm Maguire wrote:
> Greetings! On 3 of the 11 Debian architectures (i386, m68k, and ia64),
> the cdecl calling convention is available...
> ...
> 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.
>
In CSL/CCL what I do to support arbitrary arg counts involves that ugly
switch statement up to some fixed limit, but beyond that I do what is in
effect a source-code remapping so that args N, N+1, N+2,... get packed
into a regular Lisp vector and passed as one argument
Eg a call
(f a1 a2 a3 a4 ... a20, a21, ...)
is mapped to
(f a1 a2 a3 a4 ... (vector a20 a21 ...))
and a function definition
(defun f (a1 ... a20 ...)
... a23 ...)
becomes
(defun f (a1 ... vec-of-rest)
... (elt vec-of-rest 4) ...)
This clearly carries an overhead in performance in such cases but comes
closer to living within the C standard.
Arthur