gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Re: [Axiom-developer] portable cdecl 'elliptic' function cal


From: Arthur Norman
Subject: [Gcl-devel] Re: [Axiom-developer] portable cdecl 'elliptic' function calls
Date: Tue, 29 Jul 2003 07:50:18 +0100 (GMT Daylight Time)

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]