* Paolo Bonzini ([email protected]) wrote: > On 11/12/2010 01:08 PM, Mathieu Desnoyers wrote: >> * Paolo Bonzini ([email protected]) 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).
How about we start by implementing uatomic_and/uatomic_or that return void, and if we ever need uatomic_return_and/uatomic_return_or (see my other mail), we add them ? Otherwise we'll be stucked with heavily synchronized operations to return a value people just don't care about. By the way, uatomic_add/uatomic_dec don't return anything. Mathieu > > So I chose the second. > > Paolo > > _______________________________________________ > ltt-dev mailing list > [email protected] > http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
