summaryrefslogtreecommitdiffstats
path: root/lib/zassert.h
diff options
context:
space:
mode:
authorRick Balocca <rbalocca@vyatta.com>2008-10-16 17:39:55 -0700
committerRick Balocca <rbalocca@vyatta.com>2008-10-16 17:39:55 -0700
commit04c7298b3684ddda4e6669f14374e2377deb04ea (patch)
treeb3c11943294ffc282863dbca418d408a7869f86f /lib/zassert.h
parent1581cf27e9e187a12f25221cc42123a056469adb (diff)
parentfa3e86a1a7559808ba5e32374e35d387472567c8 (diff)
downloadquagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.bz2
quagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.xz
Merge branch 'islavista'
Conflicts: debian/changelog
Diffstat (limited to 'lib/zassert.h')
-rw-r--r--lib/zassert.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/zassert.h b/lib/zassert.h
index 79126760..123aee16 100644
--- a/lib/zassert.h
+++ b/lib/zassert.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)