summaryrefslogtreecommitdiffstatshomepage
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-12-29 00:51:06 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-12-29 00:51:24 +0200
commit361909e3ca8a44632c918aeed2c3426b970068fc (patch)
treec23599a085647767e83f903f2f999e7ba42256d2 /py/mpconfig.h
parent1ee1785bed2dc899d92c15047face797f859f1c9 (diff)
downloadmicropython-361909e3ca8a44632c918aeed2c3426b970068fc.tar.gz
micropython-361909e3ca8a44632c918aeed2c3426b970068fc.zip
py: Add MP_LIKELY(), MP_UNLIKELY() macros to help branch prediction.v1.3.8
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 170033240e..76f31e48e9 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -562,3 +562,13 @@ typedef double mp_float_t;
#ifndef MP_WEAK
#define MP_WEAK __attribute__((weak))
#endif
+
+// Condition is likely to be true, to help branch prediction
+#ifndef MP_LIKELY
+#define MP_LIKELY(x) __builtin_expect((x), 1)
+#endif
+
+// Condition is likely to be false, to help branch prediction
+#ifndef MP_UNLIKELY
+#define MP_UNLIKELY(x) __builtin_expect((x), 0)
+#endif