Introduce the likely() and unlikely() macros, as used in Linux.
They are compiler-dependent hints that a particular boolean expression
is likely to be true or false, respectively.
Currently only implemented for gcc.
# define X86_MEMORY 0
#endif
+/*
+ * Hints to the compiler that a particular branch of code is more or
+ * less likely to be taken.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 3
+# define likely(x) __builtin_expect(!!(x), 1)
+# define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+# define likely(x) (!!(x))
+# define unlikely(x) (!!(x))
+#endif
+
#endif /* NASM_COMPILER_H */
return;
}
- if (s->blk_len == SAA_BLKLEN) {
+ if (likely(s->blk_len == SAA_BLKLEN)) {
ix = posn >> SAA_BLKSHIFT;
s->rpos = posn & (SAA_BLKLEN-1);
} else {
return;
}
- if (s->blk_len == SAA_BLKLEN) {
+ if (likely(s->blk_len == SAA_BLKLEN)) {
ix = posn >> SAA_BLKSHIFT;
s->wpos = posn & (SAA_BLKLEN-1);
} else {