From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXte7-0006Ax-Ot for qemu-devel@nongnu.org; Thu, 11 Aug 2016 13:19:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXte5-0000uz-Hg for qemu-devel@nongnu.org; Thu, 11 Aug 2016 13:19:54 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:34938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXte5-0000ud-9u for qemu-devel@nongnu.org; Thu, 11 Aug 2016 13:19:53 -0400 Received: by mail-wm0-x233.google.com with SMTP id f65so4581210wmi.0 for ; Thu, 11 Aug 2016 10:19:53 -0700 (PDT) References: <1467392693-22715-1-git-send-email-rth@twiddle.net> <1467392693-22715-3-git-send-email-rth@twiddle.net> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1467392693-22715-3-git-send-email-rth@twiddle.net> Date: Thu, 11 Aug 2016 18:20:01 +0100 Message-ID: <87vaz7b4u6.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 02/27] atomics: add atomic_op_fetch variants List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, cota@braap.org, pbonzini@redhat.com, peter.maydell@linaro.org, serge.fdrv@gmail.com Richard Henderson writes: > From: "Emilio G. Cota" > > This paves the way for upcoming work. > > Signed-off-by: Emilio G. Cota > Message-Id: <1467054136-10430-9-git-send-email-cota@braap.org> Reviewed-by: Alex Bennée > --- > include/qemu/atomic.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h > index a5531da..d75bfde 100644 > --- a/include/qemu/atomic.h > +++ b/include/qemu/atomic.h > @@ -163,6 +163,14 @@ > #define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST) > #define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST) > > +#define atomic_inc_fetch(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST) > +#define atomic_dec_fetch(ptr) __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST) > +#define atomic_add_fetch(ptr, n) __atomic_add_fetch(ptr, n, __ATOMIC_SEQ_CST) > +#define atomic_sub_fetch(ptr, n) __atomic_sub_fetch(ptr, n, __ATOMIC_SEQ_CST) > +#define atomic_and_fetch(ptr, n) __atomic_and_fetch(ptr, n, __ATOMIC_SEQ_CST) > +#define atomic_or_fetch(ptr, n) __atomic_or_fetch(ptr, n, __ATOMIC_SEQ_CST) > +#define atomic_xor_fetch(ptr, n) __atomic_xor_fetch(ptr, n, __ATOMIC_SEQ_CST) > + > /* And even shorter names that return void. */ > #define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)) > #define atomic_dec(ptr) ((void) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)) > @@ -358,6 +366,15 @@ > #define atomic_fetch_and __sync_fetch_and_and > #define atomic_fetch_or __sync_fetch_and_or > #define atomic_fetch_xor __sync_fetch_and_xor > + > +#define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1) > +#define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1) > +#define atomic_add_fetch __sync_add_and_fetch > +#define atomic_sub_fetch __sync_sub_and_fetch > +#define atomic_and_fetch __sync_and_and_fetch > +#define atomic_or_fetch __sync_or_and_fetch > +#define atomic_xor_fetch __sync_xor_and_fetch > + > #define atomic_cmpxchg __sync_val_compare_and_swap > > /* And even shorter names that return void. */ -- Alex Bennée