From patchwork Fri Apr 15 14:23:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 8851411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1EC369F1D3 for ; Fri, 15 Apr 2016 14:24:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78A17200FE for ; Fri, 15 Apr 2016 14:24:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2A232012D for ; Fri, 15 Apr 2016 14:24:17 +0000 (UTC) Received: from localhost ([::1]:35123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ar4fR-0000cv-6y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Apr 2016 10:24:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ar4f8-0000Q3-Ck for qemu-devel@nongnu.org; Fri, 15 Apr 2016 10:23:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ar4f7-0007eT-FX for qemu-devel@nongnu.org; Fri, 15 Apr 2016 10:23:58 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:35601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ar4f7-0007eL-9b for qemu-devel@nongnu.org; Fri, 15 Apr 2016 10:23:57 -0400 Received: by mail-wm0-x234.google.com with SMTP id a140so33782807wma.0 for ; Fri, 15 Apr 2016 07:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MwJge05xJGiu6diw2QB+mFG9dUL7UYDPt7m6y9AStgM=; b=exWMAAQ/smk5uA0O/oY0JswlSYx+wwNsRIIZvTAeJamChxvX48/uXrvbME2GxqjYGu jwdZg1tA2j8TcUHyAPc8Ekz7hwlOBY4KYS+H0PeM8qo8QQw5VgqsquHaBD1PQnXFfLlB BX/utNXfwzRQiQIvI1LtWyf/7eygzOWgPvhbc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MwJge05xJGiu6diw2QB+mFG9dUL7UYDPt7m6y9AStgM=; b=mbffLvTI2QMXyDanGl9l2JVKZ10AALDDoTcahCGHTtq/Hs5NaKDMycMOElBL6eFAl0 zvU86wVPRI1vKOziLlcw4kS6yDE1wohbmhfw8VnIGgPzFpXOV9ZGd7PNnu4lltXs308P EgOTL1/V+vrRjgSCir341UGfnnWiFH8U+e3b+gwix8OhSYuA8oxbTPB7X3K4cYhuhaoK qa7lEyR24gPkMjA7r2vtmVxv8GU0ovIZaiPjbHmw99hW3srMcww5ttNRrbq4fT41VZdZ uGuz8tBJRm2TLtmJ0165Tt/AM7ZXhvNwFrrT4KyZnKts2dM0aJjRDEMXuJraxnKb5+nx J0jA== X-Gm-Message-State: AOPr4FWJWO7F54qTO02zkaXs1V3Gfm7P6/uW3uFvC7el6hcGdh1icMDqGG+6G1BkNRBSJqZQ X-Received: by 10.28.146.135 with SMTP id u129mr1706390wmd.8.1460730236776; Fri, 15 Apr 2016 07:23:56 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id ys9sm49084714wjc.35.2016.04.15.07.23.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Apr 2016 07:23:53 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A460B3E055D; Fri, 15 Apr 2016 15:24:04 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org Date: Fri, 15 Apr 2016 15:23:43 +0100 Message-Id: <1460730231-1184-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1460730231-1184-1-git-send-email-alex.bennee@linaro.org> References: <1460730231-1184-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [RFC v1 04/12] atomic: introduce atomic_dec_fetch. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, claudio.fontana@huawei.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Useful for counting down. Signed-off-by: Alex Bennée Reviewed-by: Sergey Fedorov --- include/qemu/atomic.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 8f1d8d9..5dba7db 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -131,6 +131,8 @@ #define atomic_fetch_and(ptr, n) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST) #define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST) +#define atomic_dec_fetch(ptr) __atomic_sub_fetch(ptr, 1, __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)) @@ -326,6 +328,8 @@ #define atomic_fetch_or __sync_fetch_and_or #define atomic_cmpxchg __sync_val_compare_and_swap +#define atomic_dec_fetch(ptr) __sync_sub_and_fetch(ptr, 1) + /* And even shorter names that return void. */ #define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1)) #define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))