summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-10-04 21:59:24 +0100
committerJosé Fonseca <[email protected]>2009-10-04 22:03:16 +0100
commit7a2271c65963c86ec1e5d9523b2eecf9ee59fe9d (patch)
tree042e11fc827b760c1faeb13421bc3081d11852bd /src/gallium
parent77ef7050587bba43c219e9d22170237898b2bb23 (diff)
util: Make assert a no-op on non-debug builds.
This ensures that an assertion like assert(expensive_test()); won't have any penalty on release builds. It also implies that no vital code should be in assert expressions.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_debug.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index b82e7cb4d40..b8c56fd600c 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -181,11 +181,14 @@ void _debug_assert_fail(const char *expr,
*
* Do not expect that the assert call terminates -- errors must be handled
* regardless of assert behavior.
+ *
+ * For non debug builds the assert macro will expand to a no-op, so do not
+ * call functions with side effects in the assert expression.
*/
#ifdef DEBUG
#define debug_assert(expr) ((expr) ? (void)0 : _debug_assert_fail(#expr, __FILE__, __LINE__, __FUNCTION__))
#else
-#define debug_assert(expr) ((void)(expr))
+#define debug_assert(expr) ((void)0)
#endif