From patchwork Tue Oct 22 09:58:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 21207 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BCBAA20BB3 for ; Tue, 22 Oct 2013 09:58:44 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id gq1sf12045152obb.2 for ; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:sender:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=LFqM7AetZZOXQ71g8FGW2BELahRFVgkvRkDdOsmgWfU=; b=cbApV/p4j8ACf50mxO885xmWDUtGtA7Iey/uwP1xRbdjnyPn+s3cffTlQCVOB80H2G sCG1zynlzNWyyh0cBuU6dkvXjh7sjIEwDLl6uNL/004RtpY1FeIrjsdr+EhP4Kwe/VcV ipyO3NBjTvftgBsjnNYqBzagDTe66isNZVbhuWb86At4YmB/Kut+2U+6FOQlJafOu4O0 CmxDX3d3dFzdjbOhxR0yVZNeRIieUfE82oqBRUzKau2Hah/Vy3ucZxs2AV1r+Up6EPqe Zdg13nPp7nvb49fP7OH2Hah97AuEIzrn8OO2F6conzJcvTQWsfrZmUB9llaaxHCxn7Uu YZfg== X-Received: by 10.182.81.7 with SMTP id v7mr8252936obx.28.1382435923718; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.105.34 with SMTP id gj2ls55336qeb.52.gmail; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) X-Received: by 10.58.155.162 with SMTP id vx2mr37839veb.46.1382435923582; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id hs8si2465142veb.136.2013.10.22.02.58.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 02:58:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id id10so1341011vcb.12 for ; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) X-Gm-Message-State: ALoCoQmHroVVNmZNGFgZ13bkeEPP4BPP8u/rwbZ+xU5RO4R616CCTbyNSZOX2wprJQ0fzwtBpibl X-Received: by 10.220.181.136 with SMTP id by8mr14701520vcb.11.1382435923389; Tue, 22 Oct 2013 02:58:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp217606vcz; Tue, 22 Oct 2013 02:58:42 -0700 (PDT) X-Received: by 10.194.178.166 with SMTP id cz6mr1350025wjc.53.1382435922234; Tue, 22 Oct 2013 02:58:42 -0700 (PDT) Received: from chiark.greenend.org.uk (v6.chiark.greenend.org.uk. [2001:ba8:1e3::]) by mx.google.com with ESMTPS id s4si909817wiv.8.2013.10.22.02.58.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Oct 2013 02:58:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pmaydell@chiark.greenend.org.uk designates 2001:ba8:1e3:: as permitted sender) client-ip=2001:ba8:1e3::; Received: by chiark.greenend.org.uk (Debian Exim 4.72 #1) with local (return-path pmaydell@chiark.greenend.org.uk) id 1VYYjZ-0004nn-By; Tue, 22 Oct 2013 10:58:41 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Anthony Liguori , Paolo Bonzini Subject: [PATCH for-1.7] atomic.h: Fix build with clang Date: Tue, 22 Oct 2013 10:58:41 +0100 Message-Id: <1382435921-18438-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 Sender: Peter Maydell X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.181 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , clang defines __ATOMIC_SEQ_CST but its implementation of the __atomic_exchange() builtin differs from that of gcc. Move the __clang__ branch of the ifdef ladder to the top and fix its implementation (there is no such builtin as __sync_exchange), so we can compile with clang again. Signed-off-by: Peter Maydell Reviewed-by: Paolo Bonzini --- I don't have access to a Linux box with clang, so this is only tested on MacOSX clang, but I believe it to be both required and correct for all clang platforms. include/qemu/atomic.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 0aa8913..492bce1 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -168,14 +168,14 @@ #endif #ifndef atomic_xchg -#ifdef __ATOMIC_SEQ_CST +#if defined(__clang__) +#define atomic_xchg(ptr, i) __sync_swap(ptr, i) +#elif defined(__ATOMIC_SEQ_CST) #define atomic_xchg(ptr, i) ({ \ typeof(*ptr) _new = (i), _old; \ __atomic_exchange(ptr, &_new, &_old, __ATOMIC_SEQ_CST); \ _old; \ }) -#elif defined __clang__ -#define atomic_xchg(ptr, i) __sync_exchange(ptr, i) #else /* __sync_lock_test_and_set() is documented to be an acquire barrier only. */ #define atomic_xchg(ptr, i) (smp_mb(), __sync_lock_test_and_set(ptr, i))