From 097bb4b229c78120a1cf3771b1d0cdca31a93101 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 9 Dec 2011 21:00:44 +0200 Subject: [PATCH] WITH-SPINLOCK compatibility layer was broken Copy-paste damage from WITH-RECURSIVE-LOCK, looks like. We don't have a WITH-LOCK and never did, should be WITH-MUTEX. --- src/code/thread.lisp | 2 +- tests/threads.impure.lisp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/code/thread.lisp b/src/code/thread.lisp index a780b16..5188793 100644 --- a/src/code/thread.lisp +++ b/src/code/thread.lisp @@ -95,7 +95,7 @@ stale value, use MUTEX-OWNER instead." (sb!xc:defmacro with-spinlock ((lock) &body body) (deprecation-warning :early "1.0.53.11" 'with-recursive-spinlock 'with-mutex) - `(with-lock (,lock) + `(with-mutex (,lock) ,@body)) (sb!xc:defmacro without-thread-waiting-for ((&key already-without-interrupts) &body body) diff --git a/tests/threads.impure.lisp b/tests/threads.impure.lisp index 71eb25e..8bd9f19 100644 --- a/tests/threads.impure.lisp +++ b/tests/threads.impure.lisp @@ -1403,3 +1403,26 @@ (let ((res (list (sb-thread:join-thread t1) (sb-thread:join-thread t2)))) (assert (equal '(:ok :ok) res))))) + +(with-test (:name :spinlock-api) + (let* ((warned 0) + (funs + (handler-bind ((sb-int:early-deprecation-warning (lambda (_) + (declare (ignore _)) + (incf warned)))) + (list (compile nil `(lambda (lock) + (sb-thread::with-spinlock (lock) + t))) + (compile nil `(lambda () + (sb-thread::make-spinlock :name "foo"))) + (compile nil `(lambda (lock) + (sb-thread::get-spinlock lock))) + (compile nil `(lambda (lock) + (sb-thread::release-spinlock lock))))))) + (assert (eql 4 warned)) + (handler-bind ((warning #'error)) + (destructuring-bind (with make get release) funs + (let ((lock (funcall make))) + (funcall get lock) + (funcall release lock) + (assert (eq t (funcall with lock)))))))) -- 1.7.10.4