From: Christophe R. <cr...@us...> - 2009-08-22 15:43:32
|
Update of /cvsroot/sbcl/sbcl/tests In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18621/tests Modified Files: compiler.pure.lisp Log Message: x86 sap fixes The sap-ref-with-offset stuff was wrong in that the displacement was multiplied by a notional element size, rather than being uniformly treated as a number of bytes. Mostly this codepath wasn't exposed at all (other than with sap-ref-8, which worked by "accident"), but attempts to implement UTF-16, which requires (sap-ref-16 sap (+ offset 2)), showed up the problem. Index: compiler.pure.lisp =================================================================== RCS file: /cvsroot/sbcl/sbcl/tests/compiler.pure.lisp,v retrieving revision 1.209 retrieving revision 1.210 diff -u -d -r1.209 -r1.210 --- compiler.pure.lisp 12 Aug 2009 11:14:16 -0000 1.209 +++ compiler.pure.lisp 22 Aug 2009 15:43:20 -0000 1.210 @@ -3288,3 +3288,15 @@ (test 'not-a-float) (when (member name '(decode-float integer-decode-float)) (test sb-ext:single-float-positive-infinity)))))) + +(with-test (:name :sap-ref-16) + (let* ((fun (compile nil `(lambda (x y) + (declare (type sb-sys:system-area-pointer x) + (type (integer 0 100) y)) + (sb-sys:sap-ref-16 x (+ 4 y))))) + (vector (coerce '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) + '(simple-array (unsigned-byte 8) (*)))) + (sap (sb-sys:vector-sap vector)) + (ret (funcall fun sap 0))) + ;; test for either endianness + (assert (or (= ret (+ (* 5 256) 4)) (= ret (+ (* 4 256) 5)))))) |