From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8uWO-0008Ed-2x for qemu-devel@nongnu.org; Fri, 03 Jun 2016 15:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8uWK-000528-T2 for qemu-devel@nongnu.org; Fri, 03 Jun 2016 15:12:40 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36392) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8uWJ-000511-KO for qemu-devel@nongnu.org; Fri, 03 Jun 2016 15:12:36 -0400 Received: by mail-wm0-x232.google.com with SMTP id n184so9283630wmn.1 for ; Fri, 03 Jun 2016 12:12:35 -0700 (PDT) References: <1460730231-1184-1-git-send-email-alex.bennee@linaro.org> <1460730231-1184-7-git-send-email-alex.bennee@linaro.org> <5751B411.8010808@gmail.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <5751B411.8010808@gmail.com> Date: Fri, 03 Jun 2016 20:12:44 +0100 Message-ID: <87h9da6q8j.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v1 05/12] atomic: introduce cmpxchg_bool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, qemu-devel@nongnu.org, mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com Sergey Fedorov writes: > On 15/04/16 17:23, Alex Bennée wrote: >> diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h >> index 5dba7db..94e7110 100644 >> --- a/include/qemu/atomic.h >> +++ b/include/qemu/atomic.h >> @@ -123,6 +123,16 @@ >> _old; \ >> }) >> >> +#define atomic_bool_cmpxchg(ptr, old, new) \ >> + ({ \ >> + typeof(*ptr) _old = (old), _new = (new); \ >> + bool r; \ >> + r = __atomic_compare_exchange(ptr, &_old, &_new, false, \ >> + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ >> + r; \ >> + }) >> + >> + > > Could be more simple: > > #define atomic_bool_cmpxchg(ptr, old, new) \ > ({ \ > typeof(*ptr) _old = (old), _new = (new); \ > __atomic_compare_exchange(ptr, &_old, &_new, false, \ > __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ > }) OK that makes sense. I'll have to ask my toolchain colleague what the rules are for results from {} blocks. -- Alex Bennée