summaryrefslogtreecommitdiffstats
path: root/src/gallium/include
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-01-04 08:40:04 -0700
committerBrian Paul <[email protected]>2012-01-05 08:19:23 -0700
commit188aca34923d109323e0e1a882c69f2b422b5cae (patch)
treebbda5ae9759642ae540fe0bbbccb474ebe483728 /src/gallium/include
parent6aed626c35db96c99106e2c12ef23dc58965ece0 (diff)
gallium: add STATIC_ASSERT macro
Diffstat (limited to 'src/gallium/include')
-rw-r--r--src/gallium/include/pipe/p_compiler.h11
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 6ac36447638..1daa5abdb85 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