optimize problem
I created the two functions below to copy between byte vectors and foreign memory based on the example in the documentation link.
http://www.lispworks.com/documentation/lw70/LW/html/lw-61.htm
I created some test code and get the correct results. But when I tried to use the same functions outside my test application (same environment, compiled the same way), it is not working. In particular, if I check the results of byte-to-foreign-vector, the bytes do not match the input array.
If I comment out (optimize (safety 0)), I get the correct results in all cases.
Bug or am I missing something obvious?
Thanks,
John DeSoi, Ph.D.
(defun byte-from-foreign-vector (byte-vector foreign-vector length)
(declare (optimize (safety 0))
(type (simple-array (unsigned-byte 8) 1) byte-vector)
(fixnum length))
(dotimes (index length)
(declare (type fixnum index))
(setf (aref byte-vector index) (fli:foreign-typed-aref '(unsigned-byte 8) foreign-vector index))))
(defun byte-to-foreign-vector (byte-vector foreign-vector length)
(declare (optimize (safety 0))
(type (simple-array (unsigned-byte 8) 1) byte-vector)
(fixnum length))
(dotimes (index length)
(declare (type fixnum index))
(setf (fli:foreign-typed-aref '(unsigned-byte 8) foreign-vector index) (aref byte-vector index))))
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html