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 From: Sean Bruno Date: Tue, 14 Jun 2016 10:47:47 -0700 Message-Id: <20160614174747.27840-1-sbruno@freebsd.org> Subject: [Qemu-devel] [PATCH] Disable atomic macros which conflict with C++ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sean Bruno 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. */ -- 2.8.4