summaryrefslogtreecommitdiffstats
path: root/lib/zassert.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zassert.h')
-rw-r--r--lib/zassert.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/zassert.h b/lib/zassert.h
index 525d866c..123aee16 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $
*/
#ifndef _QUAGGA_ASSERT_H
@@ -17,9 +17,17 @@ extern void _zlog_assert_failed (const char *assertion, const char *file,
#define __ASSERT_FUNCTION NULL
#endif
-#define zassert(EX) ((void)((EX) ? 0 : \
- (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
- __ASSERT_FUNCTION), 0)))
+#ifdef __GNUC__
+#define UNLIKELY(EX) __builtin_expect(!!(EX), 0)
+#define LIKELY(EX) __builtin_expect(!!(EX), 1)
+#else
+#define UNLIKELY(EX) (EX)
+#define LIKELY(EX) (EX)
+#endif
+
+#define zassert(EX) ((void)(UNLIKELY(EX) ? 0 : \
+ (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
+ __ASSERT_FUNCTION), 0)))
#undef assert
#define assert(EX) zassert(EX)