[cffi-devel] [PATCH] Shareable Vectors for ECL.

David Brown lisp at davidb.org
Fri Oct 17 05:41:51 UTC 2008


On Thu, Oct 16, 2008 at 09:11:59PM +0100, Luís Oliveira wrote:

>Can you perhaps resend the patch as an attachment (through darcs send
>-o) instead of inlining it?

Darcs does seem to be rather picky about its patches.  The patch is
attached.

David
-------------- next part --------------
Mon Oct 13 21:01:42 PDT 2008  David Brown <lisp at davidb.org>
  * Shareable Vectors for ECL.
  
  ECL uses a non-moving, conservative garbage collector, so shareable
  byte vectors can be implemented just by using a pointer to the data.

New patches:

[Shareable Vectors for ECL.
David Brown <lisp at davidb.org>**20081014040142
 
 ECL uses a non-moving, conservative garbage collector, so shareable
 byte vectors can be implemented just by using a pointer to the data.
] hunk ./src/cffi-ecl.lisp 128
+;;;# Shareable Vectors
+;;;
+;;; This interface is very experimental.  WITH-POINTER-TO-VECTOR-DATA
+;;; should be defined to perform a copy-in/copy-out if the Lisp
+;;; implementation can't do this.
+
+(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, so this
+;;; isn't nearly as hard to do.
+(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))
+

Context:

[Fix SBCL %CLOSE-FOREIGN-LIBRARY wrt changes in 1.0.21.15
Stelian Ionescu <sionescu at common-lisp.net>**20081009231840
 
 %CLOSE-FOREIGN-LIBRARY makes use of SB-ALIEN::SHARED-OBJECT-FILE which
 has disappeared in 1.0.21.15 - replaced by SHARED-OBJECT-PATHNAME, so
 I've added a readtime conditional that detects the right accessor.
] 
[gendocs.sh fix: pass --no-userinit to sbcl
Luis Oliveira <loliveira at common-lisp.net>**20080926205112] 
[Update SCL port.
Luis Oliveira <loliveira at common-lisp.net>**20080926195008
 
 Patch courtesy of Douglas Crosher.
] 
[TAG 0.10.2
Luis Oliveira <loliveira at common-lisp.net>**20080912133500] 
[update cffi.asd for version 0.10.2
Luis Oliveira <loliveira at common-lisp.net>**20080912133456] 
[TODO cleanup
Luis Oliveira <loliveira at common-lisp.net>**20080912133424] 
[Fix handling of the T clause in DEFINE-FOREIGN-LIBRARY
Luis Oliveira <loliveira at common-lisp.net>**20080912133350
 
 - Added regression test: LIBRARY.T-CLAUSE.
 
 Bug report and initial patch courtesy of Kalyanov Dmitry.
] 
[Add wrapper directives PROCLAIM and DECLAIM.
Stelian Ionescu <sionescu at common-lisp.net>**20080830083833] 
[Add option BASE-TYPE to groveler directives CENUM and CONSTANTENUM.
Stelian Ionescu <sionescu at common-lisp.net>**20080822144342] 
[Small fix to the manual: use @var instead of @code in CENUM and CONSTANTENUM docs.
Stelian Ionescu <sionescu at common-lisp.net>**20080822143956] 
[Add option DEFINE-CONSTANTS to groveler directives CENUM and CONSTANTENUM.
Stelian Ionescu <sionescu at common-lisp.net>**20080822141800
 
 If DEFINE-CONSTANTS is non-null, the enum members will also be defined
 as constants.
] 
[Make groveler directive CONSTANT more robust.
Stelian Ionescu <sionescu at common-lisp.net>**20080822141527
 
 If a constant's name is a keyword, change it to a symbol
 interned in the current package.
] 
[manual: restore colorization workingness
Luis Oliveira <loliveira at common-lisp.net>**20080822140947] 
[manual/groveller: fix ctype's documentation
Luis Oliveira <loliveira at common-lisp.net>**20080822133130
 
 Reported by Stelian Ionescu.
] 
[TAG 0.10.1
Luis Oliveira <loliveira at common-lisp.net>**20080820225954] 
Patch bundle hash:
73d9e52b7965b414d40f672c4b961260c81b615d


More information about the cffi-devel mailing list