From mboxrd@z Thu Jan 1 00:00:00 1970 From: pbonzini@redhat.com (Paolo Bonzini) Date: Fri, 12 Nov 2010 13:13:29 +0100 Subject: [ltt-dev] [PATCH 2/2] introduce uatomic_and and uatomic_or In-Reply-To: <20101112120846.GB27929@Krystal> References: <1289552247-18130-1-git-send-email-pbonzini@redhat.com> <1289552247-18130-3-git-send-email-pbonzini@redhat.com> <20101112120846.GB27929@Krystal> Message-ID: <4CDD2F69.7020407@redhat.com> 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