Greetings SBCL Gurus,

Some of you may have seen my question on the openmcl-devel listserve.  This is a similar post, except concerning SBCL, which is a different LISP with different semantics for the return value of an atomic-incf.

Can the return value of an atomic-incf be relied upon as the value right before that particular incf occurrs?

Another way to ask the same question is, if I perform two atomic-incf's in a row (i.e., as simultaneously as the x86 platform will allow me), will one of the atomic-incf calls return the original value, and the other atomic-incf return the intermediate value?

E.g.:
A long time ago, in some thread far far away:
(defstruct container (val 0 :type (unsigned-bye #+x86-64 64 #-x86--64 32)))

(defvar *x* (make-container))

In a current time, with two concurrent threads

Thread A:
(sb-ext:atomic-incf (container-val *x*)) ; sets the slot in *x* to 1, returns 0

Thread B:
(sb-ext:atomic-incf (container-val *x*)) ; sets the slot in *x* to 2, returns 1

Of course if Thread B occurred before Thread A, the B transcript would have "sets the slot in *x* to 1, returns 0" and the A transcript would also change to use the numbers 2 and 1, respectively.

Hopefully between my two versions of the question, my real question is clear.

Thanks!
David

PS -- thank you whoever implemented this in 1.0.21.  It's quite nice to have.