From patchwork Tue Jun 14 17:47:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Bruno X-Patchwork-Id: 9176367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A5386021C for ; Tue, 14 Jun 2016 17:48:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1045028236 for ; Tue, 14 Jun 2016 17:48:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04406282ED; Tue, 14 Jun 2016 17:48:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 55E6E28236 for ; Tue, 14 Jun 2016 17:48:32 +0000 (UTC) Received: from localhost ([::1]:37224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCsRz-0007WF-HH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 13:48:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCsRU-0007Ru-OH for qemu-devel@nongnu.org; Tue, 14 Jun 2016 13:48:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCsRO-0004Wr-QZ for qemu-devel@nongnu.org; Tue, 14 Jun 2016 13:47:59 -0400 Received: from ignoranthack.me ([199.102.79.106]:52518 helo=mail.ignoranthack.me) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCsRO-0004Wd-MZ for qemu-devel@nongnu.org; Tue, 14 Jun 2016 13:47:54 -0400 Received: from alice.my.domain (unknown [50.136.155.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sbruno@ignoranthack.me) by mail.ignoranthack.me (Postfix) with ESMTPSA id A1D311928BE; Tue, 14 Jun 2016 17:47:52 +0000 (UTC) From: Sean Bruno To: qemu-devel@nongnu.org Date: Tue, 14 Jun 2016 10:47:47 -0700 Message-Id: <20160614174747.27840-1-sbruno@freebsd.org> X-Mailer: git-send-email 2.8.4 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 199.102.79.106 Subject: [Qemu-devel] [PATCH] Disable atomic macros which conflict with C++ 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: Sean Bruno Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP QEMU's atomic header defines a few macros which conflict with standard C++ function names, namely atomic_fetch_{add,sub,and,or}. Disable these macros when compiling for C++. See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209590 Signed-off-by: Dimitry Andric Signed-off-by: Sean Bruno --- include/qemu/atomic.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 5bc4d6c..7fe95e6 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -136,10 +136,12 @@ /* Provide shorter names for GCC atomic builtins, return old value */ #define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST) #define atomic_fetch_dec(ptr) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST) +#ifndef __cplusplus #define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST) #define atomic_fetch_sub(ptr, n) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST) #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) +#endif /* And even shorter names that return void. */ #define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)) @@ -330,10 +332,12 @@ /* Provide shorter names for GCC atomic builtins. */ #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1) #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1) +#ifndef __cplusplus #define atomic_fetch_add __sync_fetch_and_add #define atomic_fetch_sub __sync_fetch_and_sub #define atomic_fetch_and __sync_fetch_and_and #define atomic_fetch_or __sync_fetch_and_or +#endif #define atomic_cmpxchg __sync_val_compare_and_swap /* And even shorter names that return void. */