[gambit-list] Copying arrays C<->Scheme

Mikael mikael.rcv at gmail.com
Fri Apr 12 06:37:22 EDT 2013


Hi Alvaro,

You can traverse all Scm structures from C.

You have typecheckers, car, cdr, vector-ref, accessors for all the
specialized vector types and so on.

In the current Gambit version, from all I know, using these works perfectly.

As soon as Gambit goes SMP, this may be a slightly other story and only the
objects specifically allocated with ___STILL may be safe to use, we'll see
when we get there. What could be an issue would be that the GC would trig
during your C call and change all the other object references to an object
and then its physical memory location, and you'd be using the old one in
your C code.

Do you have a specific question or problem to solve?

Brgds,
Mikael

2013/4/12 Álvaro Castro-Castilla <alvaro.castro.castilla at gmail.com>

> There is one thing that I've been meaning to ask for a long time now.
>
> I see most of the people tend to create arrays in C by malloc/___alloc_rc
> and then assigning values by iterating over them via a setter function
> (also defined with c-lambda).
> Isn't there a way to directly do this with a memcpy operation? Wouldn't
> that be faster?
>
> I understand that Gambit's heap and C's heap are separate, and you need to
> copy from one another in order to avoid GC touching any of FFI-created
> memory. But is it possible to improve this process using some sort of C
> function/macro from Gambit?
>
> I really can't find any code examples or reference for this.
>
> Thank you very much.
>
> Álvaro
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130412/2ee5b0f6/attachment.htm>


More information about the Gambit-list mailing list