dovecot: Added likely() and unlikely() macros. Use unlikely() wi...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Nov 11 23:29:44 EET 2007
details: http://hg.dovecot.org/dovecot/rev/993760061348
changeset: 6788:993760061348
user: Timo Sirainen <tss at iki.fi>
date: Sun Nov 11 23:29:41 2007 +0200
description:
Added likely() and unlikely() macros. Use unlikely() with asserts.
diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
src/lib/macros.h | 16 ++++++++++++----
diffs (39 lines):
diff -r b0dc70ac3372 -r 993760061348 src/lib/macros.h
--- a/src/lib/macros.h Sun Nov 11 21:33:33 2007 +0200
+++ b/src/lib/macros.h Sun Nov 11 23:29:41 2007 +0200
@@ -168,23 +168,31 @@
# define GNUC_PRETTY_FUNCTION ""
#endif
+#ifdef __GNUC__
+# define unlikely(expr) __builtin_expect(!!(expr), 0)
+# define likely(expr) __builtin_expect(!!(expr), 1)
+#else
+# define unlikely(expr)
+# define likely(expr)
+#endif
+
/* Provide macros for error handling. */
#ifdef DISABLE_ASSERTS
# define i_assert(expr)
#elif defined (__GNUC__) && !defined (__STRICT_ANSI__)
#define i_assert(expr) STMT_START{ \
- if (!(expr)) \
+ if (unlikely(!(expr))) \
i_panic("file %s: line %d (%s): assertion failed: (%s)", \
- __FILE__, \
- __LINE__, \
+ __FILE__, \
+ __LINE__, \
__PRETTY_FUNCTION__, \
#expr); }STMT_END
#else /* !__GNUC__ */
#define i_assert(expr) STMT_START{ \
- if (!(expr)) \
+ if (unlikely(!(expr))) \
i_panic("file %s: line %d: assertion failed: (%s)", \
__FILE__, \
__LINE__, \
More information about the dovecot-cvs
mailing list