diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-03-09 21:39:19 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-03-09 21:39:19 +0000 |
commit | d62e37b4a9200c35f44176b6e3fd159f9d7d1ea2 (patch) | |
tree | a6239faefd83d9a704d7412d689114b0f8c4e54e /src/common/util.h | |
parent | d26a587309d8174f1180758fe4630ea99250752c (diff) | |
download | tor-d62e37b4a9200c35f44176b6e3fd159f9d7d1ea2.tar.gz tor-d62e37b4a9200c35f44176b6e3fd159f9d7d1ea2.zip |
r12473@Kushana: nickm | 2007-03-06 15:49:45 -0500
Excise PREDICT and PREDICT_FALSE in favor of PREDICT_LIKELY and PREDICT_UNLIKELY.
svn:r9781
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/common/util.h b/src/common/util.h index 9f37e6ad3f..1d524cf66f 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -39,17 +39,16 @@ #error "Sorry; we don't support building with NDEBUG." #else #ifdef __GNUC__ -/** Macro: evaluate the expression x, which we expect to be false. - * Used to hint the compiler that a branch won't be taken. */ -#define PREDICT_FALSE(x) PREDICT_UNLIKELY((x) == ((typeof(x)) 0)) +/* Give an int-valued version of !x that won't confuse PREDICT_UNLIKELY. */ +#define IS_FALSE_AS_INT(x) ((x) == ((typeof(x)) 0)) #else -#define PREDICT_FALSE(x) !(x) +#define IS_FALSE_AS_INT(x) !(x) #endif /** Like assert(3), but send assertion failures to the log as well as to * stderr. */ #define tor_assert(expr) do { \ - if (PREDICT_FALSE(expr)) { \ + if (PREDICT_UNLIKELY(IS_FALSE_AS_INT(expr))) { \ log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \ _SHORT_FILE_, __LINE__, __func__, #expr); \ fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \ |