1.0.5.6: compare-and-swap / instance-set-conditional refactoring
[sbcl.git] / src / code / target-defstruct.lisp
index d41ff7a..ef0761f 100644 (file)
 (defun %instance-set (instance index new-value)
   (setf (%instance-ref instance index) new-value))
 
+(defun %instance-compare-and-swap (instance index old new)
+  #!+(or x86 x86-64)
+  (%instance-compare-and-swap instance index old new)
+  #!-(or x86 x86-64)
+  (let ((n-old (%instance-ref instance index)))
+    (when (eq old n-old)
+      (%instance-set instance index new))
+    n-old))
+
 #!-hppa
 (progn
   (defun %raw-instance-ref/word (instance index)