From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBLSF-0003Dp-Pj for qemu-devel@nongnu.org; Tue, 11 Sep 2012 04:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TBLSA-0002HZ-0v for qemu-devel@nongnu.org; Tue, 11 Sep 2012 04:04:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TBLS9-0002HT-OH for qemu-devel@nongnu.org; Tue, 11 Sep 2012 04:04:13 -0400 Message-ID: <504EF077.9080107@redhat.com> Date: Tue, 11 Sep 2012 11:04:07 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1347349912-15611-1-git-send-email-qemulist@gmail.com> <1347349912-15611-2-git-send-email-qemulist@gmail.com> In-Reply-To: <1347349912-15611-2-git-send-email-qemulist@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, Anthony Liguori , Paolo Bonzini On 09/11/2012 10:51 AM, Liu Ping Fan wrote: > From: Liu Ping Fan > > If out of global lock, we will be challenged by SMP in low level, > so need atomic ops. > > This file is a wrapper of GCC atomic builtin. > > Signed-off-by: Liu Ping Fan > --- > include/qemu/atomic.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 63 insertions(+), 0 deletions(-) > create mode 100644 include/qemu/atomic.h > > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h > new file mode 100644 > index 0000000..f17145d > --- /dev/null > +++ b/include/qemu/atomic.h > @@ -0,0 +1,63 @@ > +/* > + * Simple wrapper of gcc Atomic-Builtins > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + * > + */ > +#ifndef __QEMU_ATOMIC_H > +#define __QEMU_ATOMIC_H > + > +typedef struct Atomic { > + int counter; > +} Atomic; Best to mark counter 'volatile'. > + > +static inline void atomic_set(Atomic *v, int i) > +{ > + v->counter = i; > +} > + > +static inline int atomic_read(Atomic *v) > +{ > + return v->counter; > +} > So these two operations don't get mangled by the optimizer. -- error compiling committee.c: too many arguments to function