nasmlib.h: add unlikely() to nasm_assert()
authorH. Peter Anvin <hpa@zytor.com>
Sat, 4 Jul 2009 05:55:51 +0000 (22:55 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 4 Jul 2009 05:55:51 +0000 (22:55 -0700)
We explicitly want the compiler to pessimize the taken case of the
assert, so unlikely() is appropriate here.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
nasmlib.h

index 6776c91..0cad760 100644 (file)
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -172,8 +172,11 @@ char *nasm_strndup_log(const char *, int, const char *, size_t);
  * NASM assert failure
  */
 noreturn nasm_assert_failed(const char *, int, const char *);
-#define nasm_assert(x) \
-    do { if (!(x)) nasm_assert_failed(__FILE__,__LINE__,#x); } while (0)
+#define nasm_assert(x)                                         \
+    do {                                                       \
+       if (unlikely(!(x)))                                     \
+           nasm_assert_failed(__FILE__,__LINE__,#x);           \
+    } while (0)
 
 /*
  * ANSI doesn't guarantee the presence of `stricmp' or