[ltt-dev] [PATCH 2/2] introduce uatomic_and and uatomic_or

Paolo Bonzini pbonzini at redhat.com
Fri Nov 12 07:13:29 EST 2010


On 11/12/2010 01:08 PM, Mathieu Desnoyers wrote:
> * Paolo Bonzini (pbonzini at redhat.com) wrote:
>> These are useful to flip single bits.
>
> I'm trying to figure out the semantic of these operations.
>
> are they
>
> uatomic_add / uatomic_or or uatomic_add_return / uatomic_or_return ?

They return the old value, consistently with their names (see also the 
test_uatomic.c change).  There are three possibilities:

- return nothing

- return the old value

- return the new value

Return nothing can be useful because it can be optimized on x86 as "lock 
orl (mem), reg/imm".  However, there are no other return-nothing atomic 
ops in uatomic_*.h so I decided not to provide this.

Returning the new value doesn't make sense for and/or since you cannot 
revert the operation (unlike uatomic_add which can be implemented from 
uatomic_add_return).

So I chose the second.

Paolo




More information about the lttng-dev mailing list