Sets the atomic flag pointed by obj and returns the value it had immediately before the call.
The entire operation is atomic (an atomic read-modify-write operation): the value of obj is not affected by other threads between the instant its value is read (to be returned) and the moment it is modified by this function.