WITH-SPINLOCK compatibility layer was broken
[sbcl.git] / src / code / thread.lisp
index 6e42788..5188793 100644 (file)
@@ -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)
@@ -107,15 +107,22 @@ stale value, use MUTEX-OWNER instead."
                     'progn
                     'with-local-interrupts)))
       `(let* ((,thread *current-thread*)
-              (,prev (thread-waiting-for ,thread)))
+              (,prev (progn
+                       (barrier (:read))
+                       (thread-waiting-for ,thread))))
          (flet ((exec () ,@body))
            (if ,prev
                (,without
                 (unwind-protect
                      (progn
                        (setf (thread-waiting-for ,thread) nil)
+                       (barrier (:write))
                        (,with (exec)))
-                  (setf (thread-waiting-for ,thread) ,prev)))
+                  ;; If we were waiting on a waitqueue, this becomes a bogus
+                  ;; wakeup.
+                  (when (mutex-p ,prev)
+                    (setf (thread-waiting-for ,thread) ,prev)
+                    (barrier (:write)))))
                (exec)))))))
 
 (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t))