nasmlib.h: add unlikely() to nasm_assert()

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>
This commit is contained in:
H. Peter Anvin 2009-07-03 22:55:51 -07:00
parent 7f2c476297
commit fe1ca5a09f

View File

@ -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