[Ecls-list] Safety of vector addresses.

Gabriel Dos Reis gdr at integrable-solutions.net
Tue Oct 14 03:46:02 UTC 2008


On Mon, Oct 13, 2008 at 9:03 PM, David Brown <lisp at davidb.org> wrote:
> I was wondering about the stability of item->vector.self pointers in
> ECL.  As I understand, the conservative GC never moves blocks of
> memory around, but I wanted to make sure this is correct.

I think that is correct.

>
> Basically, I'm looking to implement the shareable-byte-vector
> interface in CFFI, and wanted to make sure what I was doing was safe.
>
> Are there any plans to ever add a GC that can relocate, or is using a
> conservative GC kind of in line with the embedable part of ECL?

A GC for ECL that would move things around would uses very difficult
or very inefficient or both for systems that think of ECL as "just a library".

>From experience with CLisp, it would be good if ECL does not move to
moving collectors.

-- Gaby




>
> This is the code I'm thinking of putting into CFFI, into
> cffi-ecl.lisp:
>
> (defun make-shareable-byte-vector (size)
>   "Create a Lisp vector of SIZE bytes that can passed to
> WITH-POINTER-TO-VECTOR-DATA."
>   (make-array size :element-type '(unsigned-byte 8)))
>
> ;;; ECL, built with the Boehm GC never moves allocated data.
> (defun %vector-address (vector)
>   "Return the address of VECTOR's data."
>   (check-type vector (vector (unsigned-byte 8)))
>   (ffi:c-inline (vector) (object) :unsigned-long
>                 "(unsigned long) #0->vector.self.b8"
>                 :side-effects nil
>                 :one-liner t))
>
> (defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
>   "Bind PTR-VAR to a foreign pointer to the data in VECTOR."
>   `(let ((,ptr-var (make-pointer (%vector-address ,vector))))
>      , at body))
>
> Previously defined
> (defun make-pointer (address)
>   "Return a pointer pointing to ADDRESS."
>   (ffi:make-pointer address :void))
>
> Thanks,
> David
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list
>




More information about the ecl-devel mailing list