1.0.4.39: get rid of hardcoded mutex and spinlock slot indexes
[sbcl.git] / src / code / thread.lisp
index ab393f5..37e89ac 100644 (file)
 
 (in-package "SB!THREAD")
 
+(def!struct mutex
+  #!+sb-doc
+  "Mutex type."
+  (name nil :type (or null simple-string))
+  (value nil)
+  #!+(and sb-lutex sb-thread)
+  (lutex (make-lutex)))
+
+(def!struct spinlock
+  #!+sb-doc
+  "Spinlock type."
+  (name nil :type (or null simple-string))
+  (value 0))
+
 (sb!xc:defmacro with-mutex ((mutex &key (value '*current-thread*) (wait-p t))
                             &body body)
   #!+sb-doc
@@ -22,6 +36,7 @@ and the mutex is in use, sleep until it is available"
   (with-unique-names (got mutex1)
     `(let ((,mutex1 ,mutex)
            ,got)
+       (/show0 "WITH-MUTEX")
        (unwind-protect
             ;; FIXME: async unwind in SETQ form
             (when (setq ,got (get-mutex ,mutex1 ,value ,wait-p))
@@ -43,7 +58,8 @@ further recursive lock attempts for the same mutex succeed. It is
 allowed to mix WITH-MUTEX and WITH-RECURSIVE-LOCK for the same mutex
 provided the default value is used for the mutex."
   #!-sb-thread
-  (declare (ignore mutex)) #!+sb-thread
+  (declare (ignore mutex))
+  #!+sb-thread
   (with-unique-names (mutex1 inner-lock-p)
     `(let* ((,mutex1 ,mutex)
             (,inner-lock-p (eq (mutex-value ,mutex1) *current-thread*)))