Skip to content

Commit

Permalink
Fix for where alignment is disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
sionescu committed Jun 7, 2024
1 parent 95f3497 commit bc4b2a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions static-vectors.asd
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
:author "Stelian Ionescu <[email protected]>"
:licence "MIT"
:version (:read-file-form "version.sexp")
:defsystem-depends-on (#+sbcl :cffi-grovel)
:defsystem-depends-on (#+(and sbcl unix) :cffi-grovel)
:depends-on (:alexandria :cffi)
:pathname "src/"
:serial t
:components ((:file "pkgdcl")
(:file "constantp")
(:cffi-grovel-file "ffi-types" :if-feature (:and :sbcl :unix))
#+(and sbcl unix)
(:cffi-grovel-file "ffi-types")
(:file "impl-abcl" :if-feature :abcl)
(:file "impl-allegro" :if-feature :allegro)
(:file "impl-clasp" :if-feature :clasp)
Expand Down
18 changes: 11 additions & 7 deletions tests/static-vectors-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,41 @@
(is (equal 5 (length v)))
(is (not (mismatch v '(1 2 3 4 5)))))))

#+(and sbcl unix)
(test (make-static-vector.alignment.correct
:compile-at :definition-time)
(locally
(declare (notinline make-static-vector))
(let* ((alignment 4096)
(v (make-static-vector 5 :alignment alignment))
(data-address (pointer-address (static-vector-pointer v))))
(is (zerop (rem data-address alignment))))))
(locally
(declare (notinline make-static-vector))
(let* ((alignment 4096)
(v (make-static-vector 5 :alignment alignment))
(data-address (pointer-address (static-vector-pointer v))))
(is (zerop (rem data-address alignment))))))

#+(and sbcl unix)
(test (make-static-vector.alignment.too-small
:compile-at :definition-time)
(locally
(declare (notinline make-static-vector))
(signals error
(make-static-vector 5 :alignment 8))))

#+(and sbcl unix)
(test (make-static-vector.alignment.too-large
:compile-at :definition-time)
(locally
(declare (notinline make-static-vector))
(signals error
(make-static-vector 5 :alignment 8192))))

#+(and sbcl unix)
(test (make-static-vector.alignment.not-power-2
:compile-at :definition-time)
(locally
(declare (notinline make-static-vector))
(signals error
(make-static-vector 5 :alignment 1000))))

#-sbcl
#-(and sbcl unix)
(test (make-static-vector.alignment.unsupported
:compile-at :definition-time)
(locally
Expand Down

0 comments on commit bc4b2a1

Please sign in to comment.