From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgHjY-0007nu-Q1 for qemu-devel@nongnu.org; Sat, 03 Sep 2016 16:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgHjT-0002w9-C9 for qemu-devel@nongnu.org; Sat, 03 Sep 2016 16:40:11 -0400 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]:35801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgHjT-0002vl-5Z for qemu-devel@nongnu.org; Sat, 03 Sep 2016 16:40:07 -0400 Received: by mail-pa0-x231.google.com with SMTP id hb8so50258065pac.2 for ; Sat, 03 Sep 2016 13:40:07 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Sat, 3 Sep 2016 13:39:30 -0700 Message-Id: <1472935202-3342-3-git-send-email-rth@twiddle.net> In-Reply-To: <1472935202-3342-1-git-send-email-rth@twiddle.net> References: <1472935202-3342-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v3 02/34] atomics: add atomic_op_fetch variants List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Emilio G. Cota" From: "Emilio G. Cota" This paves the way for upcoming work. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson Message-Id: <1467054136-10430-9-git-send-email-cota@braap.org> --- include/qemu/atomic.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index f0c1db0..6e5cdd5 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -203,6 +203,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)) @@ -398,6 +406,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. */ -- 2.7.4