diff options
author | Christophe Rhodes <csr21@cantab.net> | 2015-07-29 11:15:16 +0100 |
---|---|---|
committer | Christophe Rhodes <csr21@cantab.net> | 2015-07-29 12:22:00 +0100 |
commit | 671dd1951ab7d23425267d5b53a0ee2eccf43142 (patch) | |
tree | 9297e8ab88a78895e9c3e56c9fb4ae8309173c2e | |
parent | c5d8e4f136cec057d56957953bb3cf8a72893e8c (diff) |
avoid reader error in compare-and-swap test
it's a bit contorted, but we have to avoid interning
%raw-instance-atomic-incf/word at read-time otherwise we get reader
errors before the test machinery knows that the test can be skipped
-rw-r--r-- | tests/compare-and-swap.impure.lisp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/tests/compare-and-swap.impure.lisp b/tests/compare-and-swap.impure.lisp index c6c9bcbda..4fa20bd08 100644 --- a/tests/compare-and-swap.impure.lisp +++ b/tests/compare-and-swap.impure.lisp @@ -153,25 +153,29 @@ (with-test (:name :atomic-incf-full-call-lp1381867 :skipped-on '(not (or :x86 :x86-64 :ppc))) - (locally - ;; Rebind %RAW-INSTANCE-ATOMIC-INCF/WORD as a local function. - ;; Declaring it locally notinline fails because it is marked - ;; with the ALWAYS-TRANSLATABLE attribute, so it's a bug to call it - ;; even though we've asked to call it. (Maybe that's a bug?) - ;; And I don't want to call it explictly - I want the macro to do it - ;; so that I don't have to inject any of the sign making noise and such. - (declare (disable-package-locks sb-kernel:%raw-instance-atomic-incf/word)) - (let ((b (make-box :word 0)) - (delta (- (ash 1 (1- sb-vm:n-word-bits)))) - (f (eval '#'sb-kernel:%raw-instance-atomic-incf/word))) - (flet ((sb-kernel:%raw-instance-atomic-incf/word (a b c) - (funcall f a b c))) - (assert (= (atomic-incf (box-word b) delta) 0)) - (assert (= (atomic-incf (box-word b) delta) - (ash 1 (1- sb-vm:n-word-bits)))) - (assert (= (box-word b) 0)) - (atomic-decf (box-word b)) - (assert (= (box-word b) sb-ext:most-positive-word)))))) + ;; contortions to avoid reader errors + (let* ((%riai/w (intern "%RAW-INSTANCE-ATOMIC-INCF/WORD" "SB-KERNEL")) + (form + `(locally + ;; Rebind %RAW-INSTANCE-ATOMIC-INCF/WORD as a local + ;; function. Declaring it locally notinline fails because + ;; it is marked with the ALWAYS-TRANSLATABLE attribute, so + ;; it's a bug to call it even though we've asked to call + ;; it. (Maybe that's a bug?) And I don't want to call it + ;; explictly - I want the macro to do it so that I don't + ;; have to inject any of the sign making noise and such. + (declare (disable-package-locks ,%riai/w)) + (let ((b (make-box :word 0)) + (delta (- (ash 1 (1- sb-vm:n-word-bits)))) + (f (fdefinition ',%riai/w))) + (flet ((,%riai/w (a b c) (funcall f a b c))) + (assert (= (atomic-incf (box-word b) delta) 0)) + (assert (= (atomic-incf (box-word b) delta) + (ash 1 (1- sb-vm:n-word-bits)))) + (assert (= (box-word b) 0)) + (atomic-decf (box-word b)) + (assert (= (box-word b) sb-ext:most-positive-word))))))) + (eval form))) #+sb-thread (with-test (:name (:atomic-incf/decf :threads)) |