Lisp HUG Maillist Archive

fli interface and arrays

I've gone through the ffi documentation and can't find what I'm looking for.
Please point me in the right direction, thanks inadvance.

If I have an external function that wants an array of some type (e.g. array
of ints),  is the only way to allocate and pass these values using foreign
types? 
Is there no way to have the pointer to an underlying native lisp array
(regular or static memory) passed through? 
I see that there seems to be no way to guarantee the non-execution of the
gc, so passing a regular array through would of
 course be dangerous, but what if the array was allocated using with-static?


For example, in CMUCL I can call get the addresss of a lisp array using
sys:vector-sap which is a handle to the underlying array.
(sap-int (vector-sap array)) actually gives the memory address. 

Thanks,

brad


Re: fli interface and arrays

Brad Might wrote:
> I've gone through the ffi documentation and can't find what I'm looking for.
> Please point me in the right direction, thanks inadvance.
> 
> If I have an external function that wants an array of some type (e.g. array
> of ints),  is the only way to allocate and pass these values using foreign
> types? 
> Is there no way to have the pointer to an underlying native lisp array
> (regular or static memory) passed through? 
> I see that there seems to be no way to guarantee the non-execution of the
> gc, so passing a regular array through would of
>  course be dangerous, but what if the array was allocated using with-static?
> 
> 
> For example, in CMUCL I can call get the addresss of a lisp array using
> sys:vector-sap which is a handle to the underlying array.
> (sap-int (vector-sap array)) actually gives the memory address. 
> 

LW has the same functionality, see:

http://www.lispworks.com/documentation/lw445/FLI/html/fli-142.htm#59006
http://www.lispworks.com/documentation/lw445/FLI/html/fli-123.htm#89393

using sys:in-static-area ensures that a Lisp array will not be moved
by gc.

Wade


RE: fli interface and arrays

Excellent, thank you. I didn't think to check the online documents, I was
looking at what docs currently have on my system (LW PE 4.2.0) which doesn't
have that section.

-----Original Message-----
From: Wade Humeniuk [mailto:whumeniu@telus.net] 
Sent: Thursday, May 12, 2005 12:03 PM
To: Brad Might
Cc: lisp-hug@lispworks.com
Subject: Re: fli interface and arrays

Brad Might wrote:
> I've gone through the ffi documentation and can't find what I'm looking
for.
> Please point me in the right direction, thanks inadvance.
> 
> If I have an external function that wants an array of some type (e.g.
array
> of ints),  is the only way to allocate and pass these values using foreign
> types? 
> Is there no way to have the pointer to an underlying native lisp array
> (regular or static memory) passed through? 
> I see that there seems to be no way to guarantee the non-execution of the
> gc, so passing a regular array through would of
>  course be dangerous, but what if the array was allocated using
with-static?
> 
> 
> For example, in CMUCL I can call get the addresss of a lisp array using
> sys:vector-sap which is a handle to the underlying array.
> (sap-int (vector-sap array)) actually gives the memory address. 
> 

LW has the same functionality, see:

http://www.lispworks.com/documentation/lw445/FLI/html/fli-142.htm#59006
http://www.lispworks.com/documentation/lw445/FLI/html/fli-123.htm#89393

using sys:in-static-area ensures that a Lisp array will not be moved
by gc.

Wade


Updated at: 2020-12-10 08:52 UTC