Mesa (master): gallium: add STATIC_ASSERT macro

Brian Paul brianp at kemper.freedesktop.org
Thu Jan 5 16:03:15 UTC 2012


Module: Mesa
Branch: master
Commit: 188aca34923d109323e0e1a882c69f2b422b5cae
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=188aca34923d109323e0e1a882c69f2b422b5cae

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Jan  4 08:40:04 2012 -0700

gallium: add STATIC_ASSERT macro

---

 src/gallium/include/pipe/p_compiler.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h
index 6ac3644..1daa5ab 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -308,6 +308,17 @@ void _ReadWriteBarrier(void);
 #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.
+ */
+#define STATIC_ASSERT(COND) \
+   do { \
+      typedef int static_assertion_failed[(!!(COND))*2-1]; \
+   } while (0)
+
+
 #if defined(__cplusplus)
 }
 #endif




More information about the mesa-commit mailing list