X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftarget-thread.lisp;h=19f27472de6112166f58a4ee7404e1f662c9d7e7;hb=da8cb4801a3ab35070f380e22aea3d260f9df8aa;hp=c831dc5d550d75940deada5c8ac2299a2ce2a2cc;hpb=f3a7c6b54880895d1598b1844d7e6eba98af9e53;p=sbcl.git diff --git a/src/code/target-thread.lisp b/src/code/target-thread.lisp index c831dc5..19f2747 100644 --- a/src/code/target-thread.lisp +++ b/src/code/target-thread.lisp @@ -181,25 +181,19 @@ in future versions." (declare (type (unsigned-byte 27) n)) (sb!vm::current-thread-offset-sap n)) -;;;; spinlocks -(define-structure-slot-compare-and-swap - compare-and-swap-spinlock-value - :structure spinlock - :slot value) - (declaim (inline get-spinlock release-spinlock)) ;; Should always be called with interrupts disabled. (defun get-spinlock (spinlock) (declare (optimize (speed 3) (safety 0))) (let* ((new *current-thread*) - (old (compare-and-swap-spinlock-value spinlock nil new))) + (old (sb!ext:compare-and-swap (spinlock-value spinlock) nil new))) (when old (when (eq old new) (error "Recursive lock attempt on ~S." spinlock)) #!+sb-thread (flet ((cas () - (unless (compare-and-swap-spinlock-value spinlock nil new) + (unless (sb!ext:compare-and-swap (spinlock-value spinlock) nil new) (return-from get-spinlock t)))) (if (and (not *interrupts-enabled*) *allow-with-interrupts*) ;; If interrupts are enabled, but we are allowed to enabled them, @@ -226,14 +220,9 @@ in future versions." "The value of the mutex. NIL if the mutex is free. Setfable.") #!+(and sb-thread (not sb-lutex)) -(progn - (define-structure-slot-addressor mutex-value-address +(define-structure-slot-addressor mutex-value-address :structure mutex :slot value) - (define-structure-slot-compare-and-swap - compare-and-swap-mutex-value - :structure mutex - :slot value)) (defun get-mutex (mutex &optional (new-value *current-thread*) (waitp t)) #!+sb-doc @@ -275,7 +264,7 @@ NIL. If WAITP is non-NIL and the mutex is in use, sleep until it is available." (setf (mutex-value mutex) new-value)) #!-sb-lutex (let (old) - (when (and (setf old (compare-and-swap-mutex-value mutex nil new-value)) + (when (and (setf old (sb!ext:compare-and-swap (mutex-value mutex) nil new-value)) waitp) (loop while old do (multiple-value-bind (to-sec to-usec) (decode-timeout nil) @@ -285,7 +274,7 @@ NIL. If WAITP is non-NIL and the mutex is in use, sleep until it is available." (or to-sec -1) (or to-usec 0)))) (signal-deadline))) - (setf old (compare-and-swap-mutex-value mutex nil new-value)))) + (setf old (sb!ext:compare-and-swap (mutex-value mutex) nil new-value)))) (not old)))) (defun release-mutex (mutex)