1.0.4.76: add a new style-warning for duplicate CASE keys
[sbcl.git] / src / code / thread.lisp
index 37e89ac..d327ce9 100644 (file)
@@ -73,3 +73,19 @@ provided the default value is used for the mutex."
            (release-mutex ,mutex1)))))
   #!-sb-thread
   `(locally ,@body))
+
+(sb!xc:defmacro with-spinlock ((spinlock) &body body)
+  #!-sb-thread
+  (declare (ignore spinlock))
+  #!-sb-thread
+  `(locally ,@body)
+  #!+sb-thread
+  (with-unique-names (lock got-it)
+    `(let ((,lock ,spinlock)
+           (,got-it nil))
+      (unwind-protect
+           (progn
+             (setf ,got-it (get-spinlock ,lock))
+             (locally ,@body))
+        (when ,got-it
+          (release-spinlock ,lock))))))