From 361909e3ca8a44632c918aeed2c3426b970068fc Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Mon, 29 Dec 2014 00:51:06 +0200
Subject: [PATCH] py: Add MP_LIKELY(), MP_UNLIKELY() macros to help branch
 prediction.

---
 py/mpconfig.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/py/mpconfig.h b/py/mpconfig.h
index 170033240..76f31e48e 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
-- 
GitLab