[ltt-dev] [PATCH v2 5/6] api: reimplement useful parts in compiler.h

Paolo Bonzini pbonzini at redhat.com
Sun Aug 14 13:29:06 EDT 2011


---
 tests/api.h     |   14 +-------------
 urcu/compiler.h |    7 +++++++
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/tests/api.h b/tests/api.h
index e36a570..dcd76f7 100644
--- a/tests/api.h
+++ b/tests/api.h
@@ -27,21 +27,9 @@
  * to redistribute under later versions of GPL might not be available.
  */
 
+#include <urcu/compiler.h>
 #include <urcu/arch.h>
 
-#ifndef __always_inline
-#define __always_inline inline
-#endif
-
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
-
-/* This version of stringify will deal with commas... */
-#define __stringify_in_c(...) #__VA_ARGS__
-#define stringify_in_c(...)   __stringify_in_c(__VA_ARGS__) " "
-#define __ASM_CONST(x)        x##UL
-#define ASM_CONST(x)          __ASM_CONST(x)
-
 
 /*
  * Machine parameters.
diff --git a/urcu/compiler.h b/urcu/compiler.h
index 54904cc..9875e62 100644
--- a/urcu/compiler.h
+++ b/urcu/compiler.h
@@ -61,4 +61,11 @@
 		(type *)((char *)__ptr - offsetof(type, member));	\
 	})
 
+#ifndef __always_inline
+#define __always_inline inline
+#endif
+
+#define CAA_BUILD_BUG_ON_ZERO(cond) (sizeof(struct { int:-!!(cond); }))
+#define CAA_BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
+
 #endif /* _URCU_COMPILER_H */
-- 
1.7.6





More information about the lttng-dev mailing list