All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3] atomics: Test __STDC_VERSION__ for C11 compat
@ 2016-08-24 20:44 Pranith Kumar
  2016-08-24 20:44 ` [Qemu-devel] [PATCH 2/3] atomics: Use __atomic_*_n() variant primitives Pranith Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pranith Kumar @ 2016-08-24 20:44 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Emilio G. Cota, Alex Bennée,
	Eric Blake, Markus Armbruster

This patch tries to do the Right Thing™ to test for C11 features,
which is to test __STDC_VERSION__.

Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
---
 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 43b0645..d313e6b 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -60,7 +60,7 @@
         (unsigned short)1,                                                         \
       (expr)+0))))))
 
-#ifdef __ATOMIC_RELAXED
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
 /* For C11 atomic ops */
 
 /* Manual memory barriers
@@ -210,7 +210,7 @@
 #define atomic_and(ptr, n) ((void) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST))
 #define atomic_or(ptr, n)  ((void) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST))
 
-#else /* __ATOMIC_RELAXED */
+#else /* __STDC_VERSION__ */
 
 /*
  * We use GCC builtin if it's available, as that can use mfence on
@@ -405,5 +405,5 @@
 #define atomic_and(ptr, n)     ((void) __sync_fetch_and_and(ptr, n))
 #define atomic_or(ptr, n)      ((void) __sync_fetch_and_or(ptr, n))
 
-#endif /* __ATOMIC_RELAXED */
+#endif /* __STDC_VERSION__ */
 #endif /* QEMU_ATOMIC_H */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-29 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-24 20:44 [Qemu-devel] [PATCH 1/3] atomics: Test __STDC_VERSION__ for C11 compat Pranith Kumar
2016-08-24 20:44 ` [Qemu-devel] [PATCH 2/3] atomics: Use __atomic_*_n() variant primitives Pranith Kumar
2016-08-29 10:25   ` Paolo Bonzini
2016-08-29 15:38     ` Pranith Kumar
2016-08-24 20:44 ` [Qemu-devel] [PATCH 3/3] atomics: Remove redundant barrier()'s Pranith Kumar
2016-08-29 10:11 ` [Qemu-devel] [PATCH 1/3] atomics: Test __STDC_VERSION__ for C11 compat Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.