From patchwork Tue Aug 2 17:27:32 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: 73175 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp287859qga; Tue, 2 Aug 2016 10:42:41 -0700 (PDT) X-Received: by 10.200.54.107 with SMTP id n40mr101598646qtb.44.1470159761163; Tue, 02 Aug 2016 10:42:41 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j2si2122267qtb.124.2016.08.02.10.42.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Aug 2016 10:42:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUdiC-0005Lc-K2 for patch@linaro.org; Tue, 02 Aug 2016 13:42:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUdTo-00089W-K8 for qemu-devel@nongnu.org; Tue, 02 Aug 2016 13:27:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUdTk-0002QD-DB for qemu-devel@nongnu.org; Tue, 02 Aug 2016 13:27:47 -0400 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:38884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUdTj-0002Pm-VN for qemu-devel@nongnu.org; Tue, 02 Aug 2016 13:27:44 -0400 Received: by mail-wm0-x22a.google.com with SMTP id o80so300740569wme.1 for ; Tue, 02 Aug 2016 10:27:43 -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=O1ncKwUCfJsX2bUxw06TBTsnHtMh5KDY3yxTfE9JoFU=; b=RiCoKfhwz183nY6BInMcfRUvqD1kmIm5+5ApBCpGNR+cr/HffcJF6qx3/vqIV46ThA aWA/0q0AGhLt5CAqyGTzNSDeec8E7KE/SixahTi0ry0PfNeFtl8I/W8PatherxzmLbDf HnUgkcXXTqhnc7SD4yVFfYAeshepc0Z6Ml3T0= 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=O1ncKwUCfJsX2bUxw06TBTsnHtMh5KDY3yxTfE9JoFU=; b=S7k+CQwWM3ufEMf1RgpWfYz6AM/rz192EKhO3FIQbBZ/x+7Pn1l3QdsRDyyXfsEtEn iCY6yjJgWhnfHr+bapiYWisjSunxuK/L+mGeb84qReccwS3IF9I+HhO0s5ffbQx9FKC+ 9wRYTnRhf1EMR78rR6EobDNrNuOxQUS7Fy+K1Bc9UDZZgqdT7u0RbMphCq5WMJkTxPsu GiOOp2VO/sGxcHc3qP5era1gfVfYcFfhZ+4wMS6Qr6i3JaeLpPOtWnXg/8zB9pOwrZaD iU6cHUT/nrIGUJlOtErKXSRaCKElSTFUbgd/3fi4IB0FC3L0k9+fHEe1f4tjO2UTBB2J 1z3g== X-Gm-Message-State: AEkoous3G7LkpcCuITi7KnJur8aJLnAQHTZRPG66MxQaf2vygOccud6yk6IvaVTKY3Ox8jER X-Received: by 10.194.175.170 with SMTP id cb10mr27195919wjc.17.1470158863127; Tue, 02 Aug 2016 10:27:43 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r127sm23033721wmf.23.2016.08.02.10.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Aug 2016 10:27:41 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 546E93E0458; Tue, 2 Aug 2016 18:27:50 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org, bobby.prani@gmail.com Date: Tue, 2 Aug 2016 18:27:32 +0100 Message-Id: <1470158864-17651-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470158864-17651-1-git-send-email-alex.bennee@linaro.org> References: <1470158864-17651-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::22a Subject: [Qemu-devel] [PATCH v5 01/13] 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, Sergey Fedorov , claudio.fontana@huawei.com, mark.burton@greensocs.com, jan.kiszka@siemens.com, pbonzini@redhat.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , rth@twiddle.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Useful for counting down. Signed-off-by: Alex Bennée Signed-off-by: Sergey Fedorov --- include/qemu/atomic.h | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 7e13fca..560b1af 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -160,6 +160,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)) @@ -355,6 +357,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))