axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] Axiom and GCL FFI


From: Waldek Hebisch
Subject: [Axiom-developer] Axiom and GCL FFI
Date: Wed, 27 Jun 2007 22:53:28 +0200 (CEST)

I have a modest proposal concerning FFI, which I belive will solve
many Axiom problems.  While the proposal is motivated by Axiom
needs I belive that it may be useful also to other projects.

What Axiom needs?  Main need is support for various "kernel" type
functions, which are able to quickly perform operation on 
relatively simple data.  Relatively simple means something which
is easy to manipulate in C, but in many cases more compicated
than homogeneous array.  Also, it is a must that called routines
are allowed to call malloc.  It is undesirable to give special
parameters like :static when allocating such object in Lisp.

Form my point of view constrant that data passed to foreign
function must be allocated differently than native Lisp data
means that foreign calls are not usable on general Lisp data.
Fortunatly, at higher level Axiom is a strongly typed system
which means that collection of foreign function and data
can be wrapped inside an Axiom domain.  However once I have
a piece of data which is _only_ mainipulated by foreign
functions it is natural to represent it just by a pointer,
the actual data beeing allocated by C malloc.  So the
proposal is: add to GCL a new type which can store a C
pointer.  The main operation on this type would be to pass
it to a C function or get it back as a function result.
AFAIUI for 32-bit code one can get equivalent results
just using integers.  But 64-bit code needs correct return
type, otherwise pointers would get truncated.

Given such foreign pointers one can add more operations
(like copying data between C and Lisp), for example using
macros which expand to 'clines' construct.  It would be
nice to have a standard set of operations included in GCL,
but pointer type is critical -- the other parts can be
coded using existing GCL constructs.

The other operations may include dereferencing foreign pointers
and block copy between foreign memory and Lisp.

-- 
                              Waldek Hebisch
address@hidden 




reply via email to

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