From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2FP5-00033e-Hq for qemu-devel@nongnu.org; Mon, 16 May 2016 06:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2FOz-0005Oy-FF for qemu-devel@nongnu.org; Mon, 16 May 2016 06:05:34 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:33616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2FOz-0005Or-8Y for qemu-devel@nongnu.org; Mon, 16 May 2016 06:05:29 -0400 Received: by mail-wm0-x244.google.com with SMTP id r12so16896640wme.0 for ; Mon, 16 May 2016 03:05:29 -0700 (PDT) Sender: Paolo Bonzini References: <1463196873-17737-1-git-send-email-cota@braap.org> <1463196873-17737-6-git-send-email-cota@braap.org> From: Paolo Bonzini Message-ID: <57399B5D.10409@redhat.com> Date: Mon, 16 May 2016 12:05:17 +0200 MIME-Version: 1.0 In-Reply-To: <1463196873-17737-6-git-send-email-cota@braap.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 05/18] atomics: add atomic_test_and_set_acquire List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" , QEMU Developers , MTTCG Devel Cc: Sergey Fedorov , Richard Henderson , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Peter Crosthwaite On 14/05/2016 05:34, Emilio G. Cota wrote: > This new helper expands to __atomic_test_and_set with acquire semantics > where available; otherwise it expands to __sync_test_and_set, which > has acquire semantics. > > Signed-off-by: Emilio G. Cota Non-seqcst read-modify-write operations are beyond what I expected to have in qemu/atomic.h, but I guess it's okay for test-and-set because of __sync_test_and_set. Paolo > --- > include/qemu/atomic.h | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h > index 5bc4d6c..6061a46 100644 > --- a/include/qemu/atomic.h > +++ b/include/qemu/atomic.h > @@ -113,6 +113,7 @@ > } while(0) > #endif > > +#define atomic_test_and_set_acquire(ptr) __atomic_test_and_set(ptr, __ATOMIC_ACQUIRE) > > /* All the remaining operations are fully sequentially consistent */ > > @@ -327,6 +328,8 @@ > #endif > #endif > > +#define atomic_test_and_set_acquire(ptr) __sync_lock_test_and_set(ptr, true) > + > /* Provide shorter names for GCC atomic builtins. */ > #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1) > #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1) >