X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Flate-extensions.lisp;h=7fed98879beabfaa67b68b95b01ee38f9b33f581;hb=b7f3ef098847a4cc680f6304cec735b63bb70a0a;hp=f2756dccbc36bfa12c40103b119f3dbdf7e9f724;hpb=b1a4f6376799a402903e75d111ef29bdc25e0582;p=sbcl.git diff --git a/src/code/late-extensions.lisp b/src/code/late-extensions.lisp index f2756dc..7fed988 100644 --- a/src/code/late-extensions.lisp +++ b/src/code/late-extensions.lisp @@ -48,8 +48,7 @@ ;;; Used internally, but it would be nice to provide something ;;; like this for users as well. -#!+sb-thread -(defmacro define-structure-slot-compare-and-exchange +(defmacro define-structure-slot-compare-and-swap (name &key structure slot) (let* ((dd (find-defstruct-description structure t)) (slotd (when dd (find slot (dd-slots dd) :key #'dsd-name))) @@ -57,12 +56,16 @@ (index (when slotd (dsd-index slotd)))) (unless index (error "Slot ~S not found in ~S." slot structure)) + (unless (eq t (dsd-raw-type slotd)) + (error "Cannot define compare-and-swap on a raw slot.")) + (when (dsd-read-only slotd) + (error "Cannot define compare-and-swap on a read-only slot.")) `(progn (declaim (inline ,name)) (defun ,name (instance old new) (declare (type ,structure instance) - (type ,type new)) - (sb!vm::%instance-set-conditional instance ,index old new))))) + (type ,type old new)) + (%instance-compare-and-swap instance ,index old new))))) ;;; Ditto #!+sb-thread