[Mesa-dev] [PATCH 1/2] gallium: define unreachable macro
Tobias Klausmann
tobias.johannes.klausmann at mni.thm.de
Wed Feb 11 07:47:16 PST 2015
This is done the same way for glsl et al. already
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
src/gallium/include/pipe/p_compiler.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
index fb018bf..62ba9d3 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -249,6 +249,29 @@ void _ReadWriteBarrier(void);
/**
+ * Unreachable macro. Useful for suppressing "control reaches end of non-void
+ * function" warnings.
+ */
+#ifdef HAVE___BUILTIN_UNREACHABLE
+#define unreachable(str) \
+do { \
+ assert(!str); \
+ __builtin_unreachable(); \
+} while (0)
+#elif _MSC_VER >= 1200
+#define unreachable(str) \
+do { \
+ assert(!str); \
+ __assume(0); \
+} while (0)
+#endif
+
+#ifndef unreachable
+#define unreachable(str) assert(!str)
+#endif
+
+
+/**
* Static (compile-time) assertion.
* Basically, use COND to dimension an array. If COND is false/zero the
* array size will be -1 and we'll get a compilation error.
--
2.2.2
More information about the mesa-dev
mailing list