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, 8 insertions, 8 deletions
diff --git a/lib/zassert.h b/lib/zassert.h
index 79126760..c5892b8c 100644
--- a/lib/zassert.h
+++ b/lib/zassert.h
@@ -9,17 +9,17 @@ extern void _zlog_assert_failed (const char *assertion, const char *file,
unsigned int line, const char *function)
__attribute__ ((noreturn));
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define __ASSERT_FUNCTION __func__
-#elif defined(__GNUC__)
-#define __ASSERT_FUNCTION __FUNCTION__
+#ifdef __GNUC__
+#define UNLIKELY(EX) __builtin_expect(!!(EX), 0)
+#define LIKELY(EX) __builtin_expect(!!(EX), 1)
#else
-#define __ASSERT_FUNCTION NULL
+#define UNLIKELY(EX) (EX)
+#define LIKELY(EX) (EX)
#endif
-#define zassert(EX) ((void)((EX) ? 0 : \
- (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
- __ASSERT_FUNCTION), 0)))
+#define zassert(EX) ((void)(LIKELY(EX) ? 0 : \
+ _zlog_assert_failed(#EX, __FILE__, __LINE__, \
+ __func__)))
#undef assert
#define assert(EX) zassert(EX)