5 May 2009 02:44
Static vectors suitable for FFI
Stelian Ionescu <stelian.ionescu-zeus <at> poste.it>
2009-05-05 00:44:41 GMT
2009-05-05 00:44:41 GMT
Attached is an implementation for SBCL. make-static-vector only allocates instances of (simple-array (unsigned-byte 8) (*)) but that can be extended to other unboxed arrays. The current sharable vector interface doesn't work very well because it doesn't allow me for instance to pin a list of vectors, but only a single vector at a time. Also, I'd prefer to avoid pinning at all given how it interferes with the GC. -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur.
(in-package :cffi) (declaim (inline fill-foreign-memory)) (defun fill-foreign-memory (pointer length value) "Fill LENGTH octets in foreign memory area POINTER with VALUE." (declare (sb-ext:muffle-conditions sb-ext:compiler-note)) (sb-kernel:system-area-ub8-fill value pointer 0 length)) (declaim (inline copy-foreign-memory)) (defun copy-foreign-memory (src-ptr dst-ptr length) "Copy LENGTH octets from foreign memory area SRC-PTR to DST-PTR." (sb-kernel:system-area-ub8-copy src-ptr 0 dst-ptr 0 length)) (defconstant +array-header-size+ (* 2 sb-vm:n-word-bytes)) (defun make-static-vector (size)(Continue reading)
RSS Feed