source:
trunk/abcl/patches/abcl-static-vectors.patch
Last change on this file was 15310, checked in by , 4 years ago | |
---|---|
File size: 2.4 KB |
-
src/impl-abcl.lisp
# HG changeset patch # User Mark <evenson.not.org@gmail.com> # Date 1591169635 -7200 # Wed Jun 03 09:33:55 2020 +0200 # Node ID a7e933901bf6d37ef87076d55c9a89c64a8b8192 # Parent 21795eddcbc9156a5542e9deac1960a95c668317 abcl: "final" initial implementation Conditionalize compilation under on the presence of :NIO in CL:*FEATURES* additions available abcl-1.6.2-dev and the unreleased abcl-1.7.0 See <https://github.com/armedbear/abcl/pull/221> ff. diff -r 21795eddcbc9 -r a7e933901bf6 src/impl-abcl.lisp
a b 5 5 6 6 (in-package :static-vectors) 7 7 8 #-nio 9 (error "For allocating memory via malloc() we need the :NIO-BUFFER 10 argument to CL:MAKE-ARRAY available in abcl-1.6.2-dev and the upcoming 11 abcl-1.7.0.") 12 8 13 (declaim (inline fill-foreign-memory)) 9 14 (defun fill-foreign-memory (pointer length value) 10 15 (foreign-funcall "memset" :pointer pointer :int value size-t length :pointer) … … 22 27 23 28 (declaim (inline %allocate-static-vector)) 24 29 (defun %allocate-static-vector (length element-type) 25 (flet ((size-of (element-type) 26 ;; assume 8-bit bytes 27 1)) 30 (let* ((type 31 (first element-type)) 32 (bits-per-byte 33 (second element-type)) 34 (bytes-per-element ;; ehh, not going to work well for element type not of size 8, 16, or 32 35 (ceiling bits-per-byte 8))) 36 (unless (subtypep element-type 37 '(or (unsigned-byte 8) (unsigned-byte 16) (unsigned-byte 32))) 38 (signal 'type-error :datum element-type 39 :expected-type '(or 40 (unsigned-byte 8) 41 (unsigned-byte 16) 42 (unsigned-byte 32)))) 28 43 (let* ((bytes 29 (* length (size-of element-type)))44 (* length bytes-per-element)) 30 45 (heap-pointer 31 46 (jss:new "com.sun.jna.Memory" bytes)) 32 47 (bytebuffer 33 48 (#"getByteBuffer" heap-pointer 0 bytes)) 34 49 (static-vector 35 ( ext:make-bytebuffer-byte-vector bytebuffer)))50 (make-array length :element-type element-type :nio-buffer bytebuffer))) 36 51 (setf (gethash static-vector *static-vector-pointer*) 37 52 heap-pointer) 38 53 (values
Note: See TracBrowser
for help on using the repository browser.